`
deng131
  • 浏览: 662054 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

ruby中星号(*)作用

阅读更多
1,有正常的乘法功能 2*2 1*1

2,数组*integer eg: [1,2 ,[3 , [4 ,5]]] *2 = [1,2 ,[3 , [4 ,5]] , 1,2 ,[3 , [4,5]]]

3,字符串*integer eg: "hello"*2 = "hellohello"

4,创建数组 eg:

    *a = 1,3,"as"
    a = [1,3, "as"]   

5,数组参数传入时的前缀

    eg: a= [1 , 2]

testFun(*a) == testFun(1 , 2) != testFun([1,2])
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics