Mil*_*lan 34 ruby arrays ruby-on-rails
$param = k.chomp.split("\t")
Run Code Online (Sandbox Code Playgroud)
如何找到$param它是一个数组的长度?实际上在我写作的时候
puts $param.class
Run Code Online (Sandbox Code Playgroud)
我得到了类似数组的o/p.现在我如何找到这个数组的长度?
我试过了,$param.length但它不起作用.
Sal*_*lil 37
Ref Array类
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}"
Run Code Online (Sandbox Code Playgroud)
O/P
length of $param is : 4
Run Code Online (Sandbox Code Playgroud)