Skip to content

Instantly share code, notes, and snippets.

@itang
Created August 7, 2015 02:15
Show Gist options
  • Save itang/81ace79b91026244ce3f to your computer and use it in GitHub Desktop.
Save itang/81ace79b91026244ce3f to your computer and use it in GitHub Desktop.
Crystal: Open class for nil
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