and_bool
and_bool returns the binary AND of the left- and right-hand-side arguments.
Output
output "my_bool" {
value = false && true
}
// > my_bool: false
or_bool
or_bool returns the binary OR of the left- and right-hand-side arguments.
Output
output "my_bool" {
value = false || true
}
// > my_bool: true
div
div returns the integer division of the left-hand-side argument by the
right-hand-side argument, truncating the result toward zero (11 / -3 and
-11 / 3 both return -3). Dividing by zero returns an error.
Output
output "my_int" {
value = 11 / -3
}
// > my_int: -3
eq returns true if the left- and right-hand-side arguments are equal and
false if they are not.
Output
output "is_eq" {
value = "arg" == "arg"
}
// > is_eq: true
gt returns true if the left-hand-side argument is greater than the
right-hand-side argument.
Output
output "is_gt" {
value = 2 > 1
}
// > is_gt: true
gte
gte returns true if the left-hand-side argument is greater than or equal to
the right-hand-side argument.
Output
output "is_gte" {
value = 2 >= 2
}
// > is_gte: true
lt returns true if the left-hand-side argument is less than the
right-hand-side argument.
Output
output "is_lt" {
value = 2 < 1
}
// > is_lt: false
lte
lte returns true if the left-hand-side argument is less than or equal to the
right-hand-side argument.
Output
output "is_lte" {
value = 2 <= 2
}
// > is_lte: true
neq
neq returns true if the left- and right-hand-side arguments are not equal
and false otherwise.
Output
output "is_neq" {
value = 2 != 3
}
// > is_neq: true
In Surfpool 1.6.1 and 1.7.0, != (or std::neq) only works on two integers:
comparing strings, floats or booleans panics. Until the upstream txtx runtime
fixes it, store the == result in a variable and compare that with false
(variable.same == false).
minus
minus returns the result of subtracting the right-hand-side integer argument
from the left-hand-side integer argument.
Output
output "my_integer" {
value = 10 - 6
}
// > my_integer: 4
modulo
modulo returns the remainder of dividing the left-hand-side integer argument
by the right-hand-side integer argument.
Output
output "my_mod" {
value = 10 % 3
}
// > my_mod: 1
multiply
multiply returns the product of the left-hand-side integer argument and the
right-hand-side integer argument.
Output
output "my_product" {
value = 10 * 5
}
// > my_product: 50
add
add returns the sum of the left-hand-side integer argument and the
right-hand-side integer argument.
Output
output "my_sum" {
value = 10 + 5
}
// > my_sum: 15
neg_integer
Returns the negation of the given integer.
std::neg_integer isn’t implemented in Surfpool 1.7.0: calling it panics.
Write a negative literal (-5) or subtract from zero (0 - x) instead.
Output
not_bool
Returns the logical negation of the given boolean value.
std::not_bool and the ! operator aren’t implemented in Surfpool 1.7.0:
both panic. Compare with == instead, for example value == false.
Output