Skip to content

Instantly share code, notes, and snippets.

@krisleech
Created October 22, 2019 13:46
Show Gist options
  • Select an option

  • Save krisleech/47d42aa8d5cff90a2dbe2b85c2ab2774 to your computer and use it in GitHub Desktop.

Select an option

Save krisleech/47d42aa8d5cff90a2dbe2b85c2ab2774 to your computer and use it in GitHub Desktop.
Using class in shorthand map (etc.) synatx
class Yahify
def call(str)
str + 'YAH'
end
def self.to_proc
proc { |str| new.call(str) }
end
end
"foo".reverse.then(&Yahify) # => "oofYAH
%w(one two three).map(&Yahify) # => [oneYAH, twoYAH, threeYAH]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment