erp12.fijit.option
Idiomatic Clojure wrapper around the scala.Option abstraction.
defined?
(defined? opt)Returns true if the given option is not empty (aka is a Some). False otherwise.
empty?
(empty? opt)Returns true if the given option is empty (aka is a None). False otherwise.
get
macro
(get opt)(get opt or-else)Gets the value of the Option.
If the or-else form is not provide and the Option is empty (aka a None object) a NoSuchElementException will be thrown. If or-else is provided, the form will be evaluated in the case of a None.
Examples:
(get (option 1)) ; => 1
(get none) ; throws NoSuchElementException
(get none :default) ; => :default
(get none (throw (ex-info "Oh no!" {}))) ; throws ExceptionInfo
get-or-nil
(get-or-nil opt)Get’s the value of the Option or returns nil if option is empty (aka None).
none
An instance of scala.None.
option
(option)(option value)Create a scala.Option. If no value is given, or the value is nil a scala.None will be returned. Otherwise the result will be a scala.Some that wraps the given value.