|
|
|
|
|
by dragonwriter
980 days ago
|
|
> 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. Can you do the general form without an explicit lambda? Probably there is a way, but its not easy. |
|