User Tools

Site Tools


01_user_documentation:07_rgg_xl:02_xl:08_object:04_generator:04_guard_operator

Guard Operator

The guard operator a :: b defines a generator expression which yields a if b is true and no value at all if b is false.

This is especially useful if a is a generator expression itself, then the guard b filters the values yielded by a. The following generator expression yields all lowercase letters from a String s:

public void run ()
{
   String s = "tEa,asAZf";
   char c;
   ((c = s.charAt(0 : s.length() - 1)) :: Character.isLowerCase(c), print(c)); // print taasf
}
01_user_documentation/07_rgg_xl/02_xl/08_object/04_generator/04_guard_operator.txt · Last modified: 2025/09/04 11:25 by gaetan