Comparison operator

In this section, you will find the information about the comparison operators.

What are they?

See below the comparison operator:

OperatorsExampleAction
gt (greater)gt(constant(3), constant(4))The operator receives two inputs and the result is true if the first value is greater than the second.
gte (greater than or equal to)gte(constant(3), constant(4))The operator receives two inputs and the result is true if the first value is greater or equal to the second.
lt (less)lt(constant(3), constant(4))The operator receives two inputs and the result is true if the first value is less than the second.
lte (less than or equal to)lte(constant(3), constant(4))The operator receives two inputs and the result is true if the first value is less or equal to the second.
eq (Equal to)eq(constant(4), constant(4))The operator receives two inputs and the result is true if the two values are equal.

Example

The example here is a screen that uses the comparison operation lt, it verifies the value counter sum and there are two possibilities:

  1. If the conditional result or is true, the Text component’s text becomes true;
  2. If it is false, it attributes the value false to the text.
fun screen() = Screen(
    navigationBar = NavigationBar(
        title = "Operations",
        showBackButton = true
    ),
    child = Container(
            children = listOf(
                Text(text = constant("The text bellow will show if 4 is below 5 or not")),
                Container(
                    children = listOf(
                        Text(
                            condition(
                                lt(constant(4), constant(5)), constant("less then 5"),
                                constant("greater then 5")).toBindString()
                        )
                    )
                ).setStyle { backgroundColor = constant("#00FF00") }
            )
        )
    )