ms11
(ms)
April 20, 2012, 10:37pm
1
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
DGerton
(DGerton)
April 21, 2012, 12:32am
2
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]
DGerton
(DGerton)
April 21, 2012, 12:35am
3
Oh, here’s with the new notation you’re using. Sorry about that.
self.outer =
func = → n { self.outer << n }
func[1]
ms11
(ms)
April 21, 2012, 11:17am
4
Thank you very much for your answer. I did not mention that I am not
using Rails in this case.
But the problem disappeared this morning - somehow.