2008-07-25
ruby中星号(*)的作用
1.有正常的乘法功能
2.数组*integer
[1,2 ,[3 , [4 ,5]]] *2 = [1,2 ,[3 , [4 ,5]] , 1,2 ,[3 , [4 ,5]]]
3.字符串*integer
"hello"*2 = "hellohello"
4.创建数组
*a = 1,3,"as" a = [1,3, "as"]
5.数组参数传入时的前缀eg:
a= [1 , 2] testFun(*a) == testFun(1 , 2) != testFun([1,2])







评论排行榜