transparent_nil 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.txt +14 -4
- data/lib/transparent_nil.rb +1 -1
- metadata +1 -1
data/README.txt
CHANGED
@@ -7,17 +7,27 @@ nil values can be quite annoying. Although it is a nice error indicator but you'
|
|
7
7
|
gets ugly with too many conditional statements that handle the nil case.
|
8
8
|
|
9
9
|
TransparentNil defines some methods for +nil+ so nil values behave like any other object. Most of them return just nil, but some are different:
|
10
|
+
|
11
|
+
nil.dup
|
12
|
+
=> nil
|
13
|
+
|
14
|
+
nil[2]
|
15
|
+
=> nil
|
16
|
+
|
10
17
|
nil.empty?
|
11
|
-
|
18
|
+
=> true
|
12
19
|
|
13
20
|
nil << [element]
|
14
|
-
|
21
|
+
=> [[element]]
|
15
22
|
|
16
23
|
nil.size
|
17
|
-
|
24
|
+
=> 0
|
18
25
|
|
19
26
|
nil.split(//)
|
20
|
-
|
27
|
+
=> []
|
28
|
+
|
29
|
+
nil <=> 1
|
30
|
+
=> nil
|
21
31
|
|
22
32
|
Think +nil+ als "nothing". You can ask for nil if you need to, but you don't have to do it so often.
|
23
33
|
|
data/lib/transparent_nil.rb
CHANGED