Created
October 22, 2019 13:46
-
-
Save krisleech/47d42aa8d5cff90a2dbe2b85c2ab2774 to your computer and use it in GitHub Desktop.
Using class in shorthand map (etc.) synatx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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