Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
changing an instance variable
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jason Lillywhite, post: 4615484"] The reason is because I have big, long algorithms inside these methods 'foo' and 'bar' and I don't want to re-write "@z = @x + @y" when I get to method 'bar'. I need to evaluate the function inside 'bar' with all the same variables except for @x. that one variable needs to be different when I run bar. Maybe I have to do this: def initialize(x, y) @x, @y = x, y end def foo @z = @x + @y end def bar(new_x) @z = new_x + @y @z * 2 end ??? - Please note that my algorithms are much larger so efficiency is my friend in this case. Thank you! [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
changing an instance variable
Top