Skip to content

Data Types

Santanu Sinha edited this page Feb 3, 2022 · 3 revisions

Hope provides the following data types:

Number

This is equivalent to java Number class and can be used to hold an int, long or double value. Hope always uses double for internal calculations and matching.

Samples

2 + 3 == 5
3.0 > 1
Parsing

All numbers with dots outside of quotes are parsed to number on both LHS and RHS of an expression.

Comparison Operators

The following operators can be used to compare with a number:

==, !=, >, >=, <, <=

Stdlib functions

The following functions can be used to operate on numbers:

  • math.add(...)
  • math.sub(lhs, rhs)
  • math.prod(...)
  • math.div(lhs, rhs)
  • math.mod(lhs, rhs)
  • math.floor(val)
  • math.ceil(val)
  • math.abs(val)
  • math. neg(val)

Boolean

This is equivalent to the java Boolean class and represents a logical true or false value.

Samples

true != FALSE

Parsing

true or false without quotes ignoring case

Comparison Operators

The following operators can be used to compare with a boolean:

==, !=

Unary operator

The following ! unary operator can be used exclusively with boolean type only.

true == !false

String

This is equivalent to a java String object and is used to represent strings in expressions.

Samples

str.len('Hello') == 5
'Something' != 'Nothing'

Parsing

Quoted alphanumeric sequence of characters containing punctuations can be used to represent strings on both LHS and RHS.

Comparison operators

The following operators can be used to compare with strings:

==
!=

Stdlib functions

The following functions can be used to operate on strings:

  • str.len
  • str.lower
  • str.upper
  • str.substr

Object

Object class is used to represent an evaluated Json node. It cannot be provided by an user as a part of an expression and is created only during evaluation time from provided Json.