[Rails] Re: Why won't this lambda thing work?
Oh, here's with the new notation you're using. Sorry about that.
self.outer = []
func = -> n { self.outer << n }
func[1]
On Friday, April 20, 2012 2:32:08 PM UTC-10, IAmNan wrote:
Are you doing this in the model, and is outer a member variable? If so, did you forget to use self on it?self.outer = []func = lambda { |n| self.outer << n }func[1]
On Friday, April 20, 2012 12:37:14 PM UTC-10, ms wrote:Hey,
thank you for reading this post.
Why won't this work?
outer = []
func = ->(n) { outer << n }
func[1]
=> outer stays empty. Why that? Since outer is readable in the lambda
function it should be changeable as it is the same instance of the
array. I am a bit confused.
Thanks you very much for your answers.
ms
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/KcMHZhKpcpQJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home