Created
August 7, 2015 02:15
-
-
Save itang/81ace79b91026244ce3f to your computer and use it in GitHub Desktop.
Crystal: Open class for nil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def hello | |
puts "hello" | |
end | |
def to (&block) | |
yield self if self | |
end | |
end | |
a = nil | |
a.hello | |
puts (a.to &.to_i) | |
puts ("100".to &.to_i) | |
puts %(env["MODE"]), ENV["MODE"]?.to &.to_i || 1000 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment