Skip to content

Instantly share code, notes, and snippets.

@SamirTalwar
Last active October 3, 2020 08:42
Show Gist options
  • Select an option

  • Save SamirTalwar/1887769 to your computer and use it in GitHub Desktop.

Select an option

Save SamirTalwar/1887769 to your computer and use it in GitHub Desktop.
module Optional
def self.of value
Of.new value
end
def self.absent
Absent.new
end
private
class Of
def initialize value
@value = value
end
def or defaultValue
@value
end
end
class Absent
def or defaultValue
defaultValue
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment