深入分析Ruby传参数
Ruby语言中的函数运用是比较简单的。不过在实际运用中同样会出现一些令人头疼的问题。比如函数传参数的问题等等。下面就让我们讨论一下Ruby传参数的相关方法。
Ruby传参数代码示例:
- def fake_modify!(str)
- strstr = str.upcase
- end
- def real_modify1!(str)
- str[0] = 65.chr
- end
- def real_modify2!(str)
- str.upcase!
- end
- str = "abcde"
- puts "original :" + str
- fake_modify!(str)
- puts "fake_modify:" + str #abcde
- real_modify1!(str)
- puts "real_modify1:" + str #Abcde
- real_modify2!(str)
- puts "real_modify2:" + str #ABCDE
相关推荐
stulen 2020-08-15
fengzhiwu 2020-08-01
liusarazhang 2020-06-28
xiaobaif 2020-06-14
lemonzhangyan 2020-06-13
Crazyshark 2020-06-13
weikaixxxxxx 2020-06-13
有梦就能实现 2020-06-10
shengnanonly 2020-06-03
oraclemch 2020-05-30
poplpsure 2020-05-27
fujuan000 2020-04-30
zuihaobushi 2020-04-30
luckymaoyy 2020-04-29
xiaoseyihe 2020-04-28
JackLang 2020-04-25
菇星獨行 2020-04-20
jyj00 2020-03-26