cube-tube/lib/coalesce.rb
Gordon Pedersen eef53251d1 Beginning refactor.
Starting with Sprites.
Still don't quite know my way around Ruby yet, so it's a learning experience.
2023-03-21 16:34:34 +11:00

18 lines
296 B
Ruby

# Handy null coalesing operator, taken from
# https://github.com/kibiz0r/coalesce/blob/bc4389ae8a8bb456cd10ec8a3523df1fc775124f/lib/coalesce.rb
class Object
def _?(x = nil)
self
end
end
class NilClass
def _?(x = nil)
if block_given?
yield
else
x
end
end
end