Zac*_*sky 5 ruby interactive ruby-on-rails
这可能是一个愚蠢的问题.但是,我是一个新手...你怎么能在交互式ruby shell中有一个多行代码?看起来你只能有一条长线.按Enter键运行代码.无论如何我可以在不运行代码的情况下跳到下一行吗?再次,抱歉,如果这是一个愚蠢的问题.谢谢.
这是一个例子:
2.1.2 :053 > a = 1
=> 1
2.1.2 :054 > b = 2
=> 2
2.1.2 :055 > a + b
=> 3
2.1.2 :056 > if a > b #The code ‘if ..." starts the definition of the conditional statement.
2.1.2 :057?> puts "false"
2.1.2 :058?> else
2.1.2 :059 > puts "true"
2.1.2 :060?> end #The "end" tells Ruby we’re done the conditional statement.
"true" # output
=> nil # returned value
Run Code Online (Sandbox Code Playgroud)
IRB可以告诉我们它评估的最后一个表达式的结果.
您可以从这里获得更多有用的信息(https://www.ruby-lang.org/en/documentation/quickstart/).
| 归档时间: |
|
| 查看次数: |
5164 次 |
| 最近记录: |