你可以在 Ruby 中使用分号吗? [英] Can you use semicolons in Ruby?

查看:46
本文介绍了你可以在 Ruby 中使用分号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在学习 Ruby 时,我注意到在所有示例中都没有分号.我知道这完全没问题,只要每个语句都在它自己的行上.但我想知道的是,你能在 Ruby 中使用分号吗?

When learning Ruby, I noticed that in all the examples there are no semicolons. I am aware that this is perfectly fine as long as each statement is on its own line. But what I am wondering is, can you use semicolons in Ruby?

推荐答案

是.

Ruby 不要求我们使用任何字符来分隔命令,除非我们想在一行中将多个语句链接在一起.在这种情况下,使用分号 (;) 作为分隔符.

Ruby doesn't require us to use any character to separate commands, unless we want to chain multiple statements together on a single line. In this case, a semicolon (;) is used as the separator.

来源:http://articles.sitepoint.com/article/学习 ruby​​-on-rails/2

这篇关于你可以在 Ruby 中使用分号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆