官术网_书友最值得收藏!

Basic operations

Like all other programming languages, Ruby comes packed with a whole bunch of operators.

Arithmetic operators

Assume a = 2 and b = 4.

Comparison operators

Assignment operators

Bitwise operators

Logical operators

Ruby range operators

The Ruby defined? operator

The defined? operator is an operator that checks whether the passed expression is defined or not. If the expression is not defined, it returns nil or else a description of the expression as a string:

  • The defined? variable: If the variable is defined, it returns true
  • The defined? method: If the method is defined, it returns true
  • The defined? super: If the method exists that can be called with superuser, it returns true
  • The defined? yield: If the code block has been passed, it returns true
主站蜘蛛池模板: 腾冲县| 郯城县| 西安市| 棋牌| 苗栗县| 烟台市| 宾川县| 利川市| 抚顺县| 东至县| 鹤庆县| 安康市| 易门县| 辽阳市| 米易县| 拉孜县| 诏安县| 沂源县| 思茅市| 松阳县| 永泰县| 万载县| 双牌县| 三河市| 梁山县| 云龙县| 高青县| 泾源县| 民县| 南华县| 安泽县| 安平县| 柏乡县| 罗定市| 杭锦旗| 浑源县| 三亚市| 桂阳县| 商南县| 雅安市| 比如县|