Navigation
Synopsis Data type to represent an optional value.
Types data Maybe[&A] = nothing() | just(&A val);
Usage import util::Maybe;
Description Data type to represent an optional result.
Examples
Maybe[int] linearSearch(list[int] l, int toFind) {
   for(i <- index(l)){
      if(l[i] == toFind) {
         return just(i);
      }
   }
   return nothing();
}
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.