Mercurial > repos > other > SevenLanguagesInSevenWeeks
comparison 1-Ruby/truthiness.rb @ 11:e0a92558400f
Add some truthiness testing
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 02 Jan 2017 21:13:00 +0000 |
parents | |
children | 8d46064c9afc |
comparison
equal
deleted
inserted
replaced
10:0374ae06729e | 11:e0a92558400f |
---|---|
1 #! /usr/bin/env ruby | |
2 | |
3 values = [ true, false, 1, 0, -1, 'some string', '', nil ] | |
4 | |
5 values.each { |val| | |
6 text = if val == nil then "nil" else "'#{val}'" end | |
7 puts "Val #{text} is truthy" if val | |
8 puts "Val #{text} is falsy" unless val | |
9 } |