Principal Engineer, Agentic GCP @googlecloud • prev @OpenAI • Building the future of work. Harness engineering. As an agent influencer, • opinions mine
TIL
[4.0.9] > predicate = Kernel.instance_method(:nil?)
=> #nil#?()>
[4.0.9] > predicate.bind_call(nil)
=> false
There are two defs for nil? in Ruby. The one in Kernel is hard coded to return false, and one on NilClass hard coded to return true.
Remarkably elegant! It removes one form of branching by exploiting method dispatch.