News for hackers. Stuff that matters.
Re:"Useless syntax sugar": Numbered block parameters in Ruby by dragonwriter on Thursday October 12, 2023 @01:24AM (#37853716)
> you can't produce "argument-less comparison operation to call later".

You absolutely can, if you know the specific one (that is, type) you need.

E.g.,

  gt = Integer.instance_method(:>).method(:bind_call)
  # gt is a two arg callable functionally equivalent to ->(a,b) { a < b } for Integer a, Any b
Of course, doing this instead of just doing:

  gt = -> { _1 > _2 }
loses Ruby duck-typing and dynamism with regard to the first parameter; which may be acceptable in some cases, but not others.

There are no comments on this comment yet.