开发者

How to find the length of an array class?

$param开发者_开发技巧 = k.chomp.split("\t")

How can I find the length of $param given that it is an array? actually when I'm writing

puts $param.class

I got the o/p like Array. Now how do I find the length of this array?

I tried $param.length but it's not working.


Ref Array class

k = "This \t is \t just \t testing"
$param=k.chomp.split("\t")
array_length= $param.length   #or $param.size
puts "length of $param is : #{array_length}"

o/p

length of $param is : 4


Try using .size like this:

$param.size
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜