guys. I tried this code:
def trap_check开发者_StackOverflow社区(payroll[][], timelive[][]) . . . end
I was trying to create a function that accepts 2-dimensional array as parameters. I was having this error:
syntax error, unexpected '[', expecting ')' def trap_check(payroll[][], timelive[][])
Can somebody pls tell me how to do it the right way??? Pls help...
In Ruby you don't declare types, so your function would just be:
def trap_check(payroll, timelive)
# code
end
And you might call it as such
trap_check([[1,2,3,4],[5,6]], [[1,1,1,1],[2,2,2,2]])
To verify if payroll is infact an array, you can just do:
payroll.is_a?(Array) #=> returns true or false
精彩评论