case

match given argument against different values and execute corresponding block


Parameters

case argument :any
     matches :dictionary :block

Returns

  • :logical

Examples

copy
x: 2 ; the main block is always evaluated! case x [ 1 -> print "x is one!" 2 -> print "x is two!" any -> print "x is none of the above" ] ; x is two!

copy
key: "one" case key [ "one" 1, ; we can also return "two" 2 ; simple constant values directly ] ; => 2

copy
case "hello" #[ hello: "hola" adios: "goodbye" ] ; => "hola"

Related