Transparent Nil¶ ↑
bklippstein.github.com/transparent_nil/frames.html
nil values can be quite annoying. Although it is a nice error indicator but you’re source code gets ugly with too many conditional statements that handle the nil case. TransparentNil defines some methods for nil
so nil values behave like any other object. Most of them return just nil, but some are different:
nil.dup => nil nil[2] => nil nil.empty? => true nil << [element] => [[element]] nil.size => 0 nil.split(//) => [] nil <=> 1 => nil
Think nil
als “nothing”. You can ask for nil if you need to, but you don’t have to do it so often.
The Kyanite gem extends the usage of nil.
Usage¶ ↑
require 'transparent_nil'
More Info¶ ↑
-
Documentation: {bklippstein.github.com/transparent_nil/frames.html github.com/transparent_nil}
-
Source code: {github.com/bklippstein/transparent_nil github.com/bklippstein}
-
License: {creativecommons.org/licenses/by-sa/3.0/de/deed.en cc-by-sa Creative Commons Attribution-Share Alike 3.0 Germany}
-
Autor: {klippstein@klippstein.com Björn Klippstein}
Disclaimer¶ ↑
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.