File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ Translations of the guide are available in the following languages:
87
87
* [Classes & Modules](#classes--modules)
88
88
* [Exceptions](#exceptions)
89
89
* [Collections](#collections)
90
+ * [Numbers](#numbers)
90
91
* [Strings](#strings)
91
92
* [Regular Expressions](#regular-expressions)
92
93
* [Percent Literals](#percent-literals)
@@ -1512,7 +1513,7 @@ condition](#safe-assignment-in-condition).
1512
1513
1513
1514
# good
1514
1515
'ruby' == some_str
1515
- 1.0.eql? x # eql? makes sense here if want to differentiate between Fixnum and Float 1
1516
+ 1.0.eql? x # eql? makes sense here if want to differentiate between Integer and Float 1
1516
1517
```
1517
1518
1518
1519
* <a name="no-cryptic-perlisms"></a>
@@ -3300,6 +3301,23 @@ resource cleanup when possible.
3300
3301
end
3301
3302
end
3302
3303
```
3304
+ ## Numbers
3305
+
3306
+ * <a name="integer-type-checking"></a>
3307
+ Use `Integer` check type of an integer number. Since `Fixnum` is platform-dependent, checking against it will
3308
+ return different results on 32-bit and 64-bit machines.
3309
+ <sup>[[link](#integer-type-checking)]</sup>
3310
+
3311
+ ```Ruby
3312
+ timestamp = Time.now.to_i
3313
+
3314
+ # bad
3315
+ timestamp.is_a? Fixnum
3316
+ timestamp.is_a? Bignum
3317
+
3318
+ # good
3319
+ timestamp.is_a? Integer
3320
+ ```
3303
3321
3304
3322
## Strings
3305
3323
You can’t perform that action at this time.
0 commit comments