Compliments Kernel#ergo.
"a".ergo{ |o| o.upcase } #=> "A" nil.ergo{ |o| o.bar } #=> nil
CREDIT: Daniel DeLorme
# File lib/facets/core/facets/kernel/ergo.rb, line 37 def ergo @_ergo ||= Functor.new{ nil } @_ergo unless block_given? end
Allows nil to create an empty hash, similar to to_a and to_s.
nil.to_h #=> {}
CREDIT: Trans
# File lib/facets/core/facets/to_hash.rb, line 268 def to_h; {}; end
See Kernel#try.
# File lib/facets/core/facets/kernel/try.rb, line 49 def try(method=nil, *args) if method nil else Functor.new{ nil } end end