How to: Count, size, length...too many choices in Ruby?
How to: Count, size, length…too many choices in Ruby?
Count, size, length…too many choices in Ruby?
I can’t seem to find a definitive answer on this and I want to make sure I understand this to the “n’th level” :-)
a = { "a" => "Hello", "b" => "World" } a.count # 2 a.size # 2 a.length # 2 a = [ 10, 20 ] a.count # 2 a.size # 2 a.length # 2
So which to use? If I want to know if a has more than one element then it doesn’t seem to matter but I want…
View On WordPress














