the nature of truth
Post on 17-Oct-2014
1.818 views
DESCRIPTION
Lightning talk on the nature of truth, originally given at the Ruby Hoedown 2008TRANSCRIPT
THE NATURE OF TRUTHAn epistemological clusterfuck
Yossef MendelssohnWorld-Renowned Truthologist
WHAT IS TRUTH?
WHAT IS TRUE?
http://en.wikipedia.org/wiki/Image:Epimenides.jpg
http://en.wikipedia.org/wiki/Image:Immanuel_Kant_(painted_portrait).jpg
http://en.wikipedia.org/wiki/Image:Foucault_Bachelard.png
http://en.wikipedia.org/wiki/Image:Truth.jpg
http://en.wikipedia.org/wiki/Image:Jules_Joseph_Lefebvre.jpg
TRUTH IN RUBY
http://blog.ianbicking.org/re-ruby-and-python-compared.html
http://t-a-w.blogspot.com/2007/07/truth-falsehood-and-voidness-in-dynamic.html
http://osdir.com/ml/lang.ruby.musing/2004-10/msg00130.html
Truth in Ruby
true
Truth in Ruby
true
42
Truth in Ruby
true
42
0
Truth in Ruby
true
42
0
‘this sentence is false’
Truth in Ruby
true
42
0
‘this sentence is false’
[ 10, ‘One’, 4 ]
Truth in Ruby
true
42
0
‘this sentence is false’
[ 10, ‘One’, 4 ]
[]
Truth in Ruby
true
42
0
‘this sentence is false’
[ 10, ‘One’, 4 ]
[]
and many more...
Truth in Ruby
Not Truth in Ruby
false
Not Truth in Ruby
false
nil
Not Truth in Ruby
false
nil
That’s it.
Not Truth in Ruby
false
nil
That’s it.
Really, stop looking.
Not Truth in Ruby
if val.empty?
if val.empty? if val and val.empty?
if val.empty? if val and val.empty?
if val.blank?
if val and val.empty?
if val
if val
if val
false
nil
That’s it.
Really, stop looking.
Not Truth in Ruby
CLEARING UP THE CONFUSION
if val
5.67 # ? 0 # Is this Perl?[] # Maybe?true # Seriously?false # C'mon!
Truthiness
http://thesituationist.files.wordpress.com/2008/02/stephen-colbert.jpg
gem install truthy
http://github.com/ymendel/truthy
5.67 # ? 0 # Is this Perl?[] # Maybe?true # Seriously?false # C'mon!
5.67.truthy? # => true0.truthy? # => true[].truthy? # => truetrue.truthy? # => truefalse.truthy? # => false
truthiness- false should not be truthy- nil should not be truthy- true should be truthy- a string should be truthy- even an empty string should be truthy- a string containing nothing but whitespace should still be truthy- a number should be truthy- zero is truthy- infinity is totally truthy- even a negative number is truthy- an array should be truthy- an empty array is truthy- an array containing only non-truthy elements: still truthy- a hash is truthy- an empty hash is truthy- an hash containing only non-truthy things: still truthy- an object is truthy
Finished in 0.02162 seconds
17 examples, 0 failures
false
nil
That’s it.
Really, stop looking.
Not Truth in Ruby