If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
[Ruby] Setter with arguments?
1 post
• Page 1 of 1
[Ruby] Setter with arguments?
The title says it all. I have nested hashes in a class and access them via methods, for example:
It is called straight-forward:
However, when I try to create a setter with these arguments, it end in an error. Ruby seems to only work with no-argument-methods as setters. I try to get something, that allows me to do that:
Since this doesn't work:
Are there any ideas, how I could achieve it nevertheless?
- Code: Select all
... (class defintition and intitializing left out)
def something(layer1, layer2)
return myHash[layer0][layer1][layer2]
end
It is called straight-forward:
- Code: Select all
myClass.something(:first, :second)
However, when I try to create a setter with these arguments, it end in an error. Ruby seems to only work with no-argument-methods as setters. I try to get something, that allows me to do that:
- Code: Select all
myClass.something(:first, :second) = someobject
Since this doesn't work:
- Code: Select all
def something(layer1, layer2)=(myobject)
myHash[layer0][layer1][layer2] = myobject
end
Are there any ideas, how I could achieve it nevertheless?
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
1 post
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 77 guests