4 ms·
Some consider Ruby blocks to not be first-class functions since calling them is different from calling methods. I don't know if I agree or not.
by lucian1900 12y ago
Some consider Ruby blocks to not be first-class functions since calling them is different from calling methods.
I don't know if I agree or not.
- vidarh 12y ago"Bare" Ruby blocks are called differently from calling methods (yield). But the moment you name a block (pass it to a method with a named block argument) or create one with "proc" or "lambda" or "Proc.new", the form you get access to it in is a Proc object, and calling it is a method call (ob.call). The distinction is quite pointless, other than as an implementation artefact for MRI, as there shouldn't be any obvious observable differences in behaviour between a bare block and a Proc (in my "eternally in progress and not very functional yet" Ruby compiler, all blocks are in fact Proc instances, though if you can tell, it's a bug)