Created
October 6, 2014 02:22
-
-
Save wildjcrt/994dc210b8f957ae3477 to your computer and use it in GitHub Desktop.
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
>> a = [1, 2, 3, 4, 5, 1, 2] | |
=> [1, 2, 3, 4, 5, 1, 2] | |
>> a.compact.size | |
=> 5 | |
>> a.compact!.size | |
NoMethodError: undefined method `size' for nil:NilClass | |
from (irb):14 | |
from /Users/wildjcrt/.rvm/rubies/ruby-2.1.3/bin/irb:11:in `<main>' |
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
>> hash=Hash.new [] | |
=> {} | |
>> hash[:foo] << 1 | |
=> [1] | |
>> hash[:foo] << 2 | |
=> [1, 2] | |
>> hash[:foo] << 3 | |
=> [1, 2, 3] | |
>> hash.each {|key, value| puts key; puts value;} | |
=> {} | |
>> hash | |
=> {} | |
>> hash.keys | |
=> [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment