2 ms·
> ... lack of first-class functions and iterators/generators, as well as the general iteration protocol. I'd love to hear what makes you say this - none of it
by e12e 3y ago
> ... lack of first-class functions and iterators/generators, as well as the general iteration protocol.
I'd love to hear what makes you say this - none of it is meaningfully true (ruby doesn't have functions, but it has blocks and callables).
It has:
https://docs.ruby-lang.org/en/master/Enumerator.html https://docs.ruby-lang.org/en/master/Enumerator.html
- djur 3y agoWhat is the distinction between a function and a proc? I would say that a proc is a (first-class) function.
- e12e 3y agoAs I said, claiming that ruby doesn't have first-class functions isn't "meaningfully true". Ruby does not have functions, only methods. But that's mostly irrelevant. https://en.m.wikipedia.org/wiki/First-class_function#Language_support https://en.m.wikipedia.org/wiki/First-class_function#Languag... > The identifier of a regular "function" in Ruby (which is really a method) cannot be used as a value or passed. It must first be retrieved into a Method or Proc object to be used as first-class data. The syntax for calling such a function object differs from calling regular methods. https://blog.appsignal.com/2018/09/04/ruby-magic-closures-in-ruby-blocks-procs-and-lambdas.html https://blog.appsignal.com/2018/09/04/ruby-magic-closures-in... > Ruby doesn’t have first-class functions, but it does have closures in the form of blocks, procs and lambdas. Blocks are used for passing blocks of code to methods, and procs and lambda’s allow storing blocks of code in variables.