Created
January 27, 2012 18:52
-
-
Save miketheman/1690297 to your computer and use it in GitHub Desktop.
ruby - moved grep from string method to enumerable
This file contains 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
ruby-1.8.7-p352 $ irb | |
1.8.7 :001 > thing = 'sometext' | |
=> "sometext" | |
1.8.7 :002 > thing.grep(/some/) | |
=> ["sometext"] | |
ruby-1.9.2-p290 $ irb | |
1.9.2p290 :001 > thing = 'sometext' | |
=> "sometext" | |
1.9.2p290 :002 > thing.grep(/some/) | |
NoMethodError: undefined method `grep' for "sometext":String | |
from (irb):2 | |
from /Users/michael/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>' | |
1.9.2p290 :003 > thing.lines.grep(/some/) | |
=> ["sometext"] | |
This has saved me just now as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you