Answer the question
In order to leave comments, you need to log in
What does the construction -> {} mean?
Hey! I often see the design (arg) -> {}
I Know Coffee and there it denotes a function. However, a = (arg) -> { 920 }
it doesn’t work :(
I googled it, but I didn’t find an answer. So, what does this construction mean?
The most interesting thing is that you have to use it yourself, without even understanding its meaning.
Answer the question
In order to leave comments, you need to log in
It's a lambda (or proc )
In short, at its core, it's a callable object. Where you store an arbitrary block with arbitrary formal variables. And at any time you have the opportunity to call a method on itcall
a = -> { |time| User.where(created_at: time) }
...
a.call(Time.now)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question