Skip to content

Instantly share code, notes, and snippets.

@jaredbc
Created May 29, 2012 02:57
Show Gist options
  • Save jaredbc/2822249 to your computer and use it in GitHub Desktop.
Save jaredbc/2822249 to your computer and use it in GitHub Desktop.
Lenses
var Option = function (value) {
this._value = value;
this._hasValue = true;
if(value == undefined || value == null) {
this._hasValue = false;
this._value = null;
}
}
Option.prototype = {
isEmpty: function() {
return !this._hasValue;
},
getOrElse: function(v) {
return this.isEmpty() ? v : this._value;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment