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

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
主站蜘蛛池模板: 略阳县| 平塘县| 泗阳县| 禹城市| 丰县| 措美县| 凌海市| 日喀则市| 乐安县| 尼玛县| 新沂市| 吴川市| 荆门市| 大厂| 柳河县| 竹溪县| 瑞丽市| 宣化县| 黑河市| 上犹县| 闽清县| 青阳县| 婺源县| 额济纳旗| 华蓥市| 涞源县| 伊宁市| 岚皋县| 安远县| 柏乡县| 秦皇岛市| 安国市| 申扎县| 荣成市| 阿图什市| 资中县| 灵璧县| 保德县| 天门市| 左云县| 尚志市|