Memoize

BasicWerk   EC Support   Technique   Facebook  

20140905123834_ruby_assoc

ruby_assoc

 

 
[22] pry(main)> a = []
=> []
 
[23] pry(main)> a << [:a, [[:aa, :foo]]]
=> [[:a, [[:aa, :foo]]]]
 
[24] pry(main)> a << [:b, [[:aa, :fooo]]]
=> [[:a, [[:aa, :foo]]], [:b, [[:aa, :fooo]]]]
 
[25] pry(main)> a.assoc(:a)
=> [:a, [[:aa, :foo]]]
 
[26] pry(main)> a.assoc(:a).last << [:zz, :foo2]
=> [[:aa, :foo], [:zz, :foo2]]
 
[27] pry(main)> a.assoc(:a)
=> [:a, [[:aa, :foo], [:zz, :foo2]]]
 
[28] pry(main)> a.assoc(:a).last.assoc(:zz).last
=> :foo2
 

 


© Shin Nakamura/BasicWerk 2014