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/-/xdVC_59NzqgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.