Miscellaneous Syntax
Miscellaneous Syntax
Ending an Expression
Ruby uses a newline as the end of an expression. When ending a line with an operator, open parentheses, comma, etc. the expression will continue.
You can end an expression with a ;
(semicolon). Semicolons are most frequently used with ruby -e
.
Indentation
Ruby does not require any indentation. Typically, ruby programs are indented two spaces.
If you run ruby with warnings enabled and have an indentation mis-match, you will receive a warning.
alias
The alias
keyword is most frequently used to alias methods. When aliasing a method, you can use either its name or a symbol:
alias new_name old_name alias :new_name :old_name
For methods, 登录查看完整内容