extractOpt
This commit is contained in:
@@ -165,6 +165,7 @@ class Kiss {
|
||||
],
|
||||
identAliases: [
|
||||
// These ones won't conflict with variables and might commonly be used with (apply)
|
||||
"extractOpt" => Symbol("Prelude.extractOpt"),
|
||||
"+" => Symbol("Prelude.add"),
|
||||
"-" => Symbol("Prelude.subtract"),
|
||||
"*" => Symbol("Prelude.multiply"),
|
||||
|
@@ -4,6 +4,7 @@ using Std;
|
||||
|
||||
import kiss.ReaderExp;
|
||||
import haxe.ds.Either;
|
||||
import haxe.ds.Option;
|
||||
import haxe.Constraints;
|
||||
import haxe.DynamicAccess;
|
||||
#if js
|
||||
@@ -76,6 +77,13 @@ class Prelude {
|
||||
};
|
||||
}
|
||||
|
||||
public static function extractOpt<T>(opt:Option<T>) {
|
||||
return switch (opt) {
|
||||
case Some(v): v;
|
||||
default: throw 'Failed to extract Option: $opt';
|
||||
};
|
||||
}
|
||||
|
||||
static function _and(values:Array<Dynamic>):Dynamic {
|
||||
for (value in values) {
|
||||
if (!truthy(value)) {
|
||||
|
Reference in New Issue
Block a user