Ruby on Rails Friday, March 3, 2017

As Colin mentioned you'd want to recalculate the variable in each method that it's used.  Global variables may work for your use case but they are not best practice and can lead to a mutable/mutex object which may not be your intended behavior.



On Mar 3, 2017, at 4:39 PM, Joe Guerra <jguerra@jginfosys.com> wrote:

ok, I thought about that.  Would it be ok to like set the instant variable to a global and use that?

$remaining = @remaining

I tried that, and it seems to have worked.  I not sure if it's the best practice though.

On Friday, March 3, 2017 at 5:21:22 PM UTC-5, Colin Law wrote:
On 3 March 2017 at 22:03, Joe Guerra <JGu...@jginfosys.com> wrote:
> Ok, how do I deal with that?

You have to recalculate the variable in each method that you need it.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/46af96c5-857d-4742-894d-be66446bf1a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment