Ruby 英语
Ruby 中使用的英语词汇有且只有下面 41 个,这些词也称为关键词或者保留词,整个编程语言就是基于这些词汇进行编写。具体如下:
__ENCODING__
- 当前程序文件使用的编码
__LINE__
- 此关键词在当前文件里出现的位置行号
__FILE__
- 当前文件的路径
- BEGIN
- 在当前程序文件中最先运行
- END
- Runs after any other code in the current file. See miscellaneous syntax
- alias
- 为一个方法创建别名建立起两个方法之间的联系
- and
- 惰性布尔(Short-circuit Boolean)值,优先级低于
&&
- begin
- 启动异常处理块
- break
- 跳出程序块
- case
- 开始一种情形(case)表达式
- class
- 创建或者打开一个类
- def
- 定义方法
- defined?
- 返回描述其参数的字符串
- do
- 开始一段程序块
- else
- The unhandled condition in case, if and unless expressions. See control expressions syntax
- elsif
- An alternate condition for an if expression. See control expressions syntax
- end
- The end of a syntax block. Used by classes, modules, methods, exception handling and control expressions.
- ensure
- Starts a section of code that is always run when an exception is raised. See exceptions syntax
- false
- Boolean false. See literals
- for
- A loop that is similar to using the each method. See control expressions syntax
- if
- Used for if and modifier if statements. See control expressions syntax
- in
- Used to separate the iterable object and iterator variable in a for loop. See control expressions syntax It also serves as a pattern in a case expression. See pattern matching
- module
- Creates or opens a module. See modules and classes syntax
- next
- Skips the rest of the block. See control expressions syntax
- nil
- A false value usually indicating “no value” or “unknown”. See literals
- not
- Inverts the following boolean expression. Has a lower precedence than
!
- or
- Boolean or with lower precedence than
||
- redo
- Restarts execution in the current block. See control expressions syntax
- rescue
- Starts an exception section of code in a begin block. See exceptions syntax
- retry
- Retries an exception block. See exceptions syntax
- return
- Exits a method. See methods syntax. If met in top-level scope, immediately stops interpretation of the current file.
- self
- The object the current method is attached to. See methods syntax
- super
- Calls the current method in a superclass. See methods syntax
- then
- Indicates the end of conditional blocks in control structures. See control expressions syntax
- true
- Boolean true. See literals
- undef
- Prevents a class or module from responding to a method call. See modules and classes syntax
- unless
- Used for unless and modifier unless statements. See control expressions syntax
- until
- Creates a loop that executes until the condition is true. See control expressions syntax
- when
- A condition in a case expression. See control expressions syntax
- while
- Creates a loop that executes while the condition is true. See control expressions syntax
- yield
- Starts execution of the block sent to the current method. See methods syntax