Type Conditions

of_type(cls): Check if object is of type

Checks if an element is an instance of the specified class.

Stream.of([1, 3.4, "A", None] \
    .filter(of_type(int)) \
    .for_each(print) # 1

not_of_type(cls: Type): Check if object is not of type

Checks if an element is not an instance of the specified class.

Stream.of([1, 3.4, "A", None] \
   .filter(not_of_type(int)) \
   .for_each(print) # 3.4, "A", None

none(): Check if object is None

Checks if an element is None.

Stream.of([1, None, "Hello", None] \
   .filter(none()) \
   .for_each(print) # None, None

not_none(): Check if object is not None

Checks if an element is not None.

true(): Check if object is True

Checks if an element is True.

not_true(): Check if object is not True

Checks if an element is not True.

false(): Check if object is False

Checks if an element is False.

not_false(): Check if object is not False

Checks if an element is not False.

length(x): Check if object has specified length

Checks if an element has the specified length.

not_length(x): Check if object does not have specified length

Checks if an element does not have the specified length.

empty(): Check if object is empty

Checks if an element is empty (e.g., an empty list, string, etc.).

not_empty(): Check if object is not empty

Checks if an element is not empty.

equal(x): Check if object is equal to the specified value

Checks if an element is equal to the specified value.

not_equal(x): Check if object is not equal to the specified value

Checks if an element is not equal to the specified value.

Last updated

Was this helpful?