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 to make sure I understand the real difference. This applies to arrays too. I get the same results. Also, I realize that count/size/length have different meanings with ActiveRecord. I'm mostly interested in pure Ruby (1.92) right now but if anyone want
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.