我刚开始学习如何编写代码,我试着运行一些基本的指令。 要开始,我有以下几点:为什么=>符号出现在我的代码中?
print 'hello'
v= "yes"
["test","words","okay"].
each do |v|
puts "This is the test word #{v}"
end
这给了我下面的出把
irb(main):053:0> print 'hello'
hello=> nil
irb(main):054:0> v= "yes"
=> "yes"
irb(main):055:0> ["test","words","okay"].
irb(main):056:0* each do |v|
irb(main):057:1* puts "This is the test word #{v}"
irb(main):058:1> end
This is the test word test
This is the test word words
This is the test word okay
=> ["test", "words", "okay"]
究竟为什么=>符号出现在我的代码到底是哪参考回到我的数组的字符串?据我了解,到目前为止,我知道=>可以用来将字符串分配给散列符号(我认为),但符号还有其他目的,它为什么在我的代码中?
'=>'表示返回值的开始。它与散列中使用的符号无关。 –
你的例子很难理解它的含义。尝试输入“1 + 2”。 – Stefan