00 - introduction
来自「O Reilly Ruby Cookbook source code」· 代码 · 共 26 行
TXT
26 行
hash = { "key1" => "val1", "key2" => "val2" }string = ""hash.each { |k,v| string << "#{k} is #{v}\n" } puts string# key1 is val1# key2 is val2#---string = ""hash.each { |k,v| string << k << " is " << v << "\n" } #---puts hash.keys.join("\n") + "\n"# key1# key2#---data = ['1', '2', '3']s = ''data.each { |x| s << x << ' and a '}s # => "1 and a 2 and a 3 and a "data.join(' and a ') # => "1 and a 2 and a 3"#---s = ""data.each_with_index { |x, i| s << x; s << "|" if i < data.length-1 }s # => "1|2|3"#---
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?