Created
November 22, 2011 03:14
-
-
Save pasberth/1384794 to your computer and use it in GitHub Desktop.
Array#=== をかっこ良く
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 Array | |
| def === other | |
| zip(other.to_ary).all? { |mine, theirs| mine === theirs } | |
| end | |
| end | |
| puts case [:lover, 'mana', 18] | |
| when [Symbol, String, Integer] then 'love!' | |
| else 'hello!' | |
| end | |
| # => love! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment