experimental[The Painless scripting language is new and is still marked as experimental. The syntax or API may be changed in the future in non-backwards compatible ways if required.]
[float]
[[painless-types]]
=== Variable types
Painless supports all of https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html[Java's types],
including array types, but adds some additional built-in types.
[float]
[[painless-def]]
==== Def
The dynamic type `def` serves as a placeholder for any other type. It adopts the behavior
of whatever runtime type it represents.
[float]
[[painless-strings]]
==== String
String constants can be declared with single quotes, to avoid escaping horrors with JSON:
All of Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html[operators] are
supported with the same precedence, promotion, and semantics.
There are only a few minor differences and add-ons:
* `==` behaves as Java's for numeric types, but for non-numeric types acts as https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-[`Object.equals()`]
* `===` and `!==` support exact reference comparison (e.g. `x === y`)
* `=~` true if a portion of the text matches a pattern (e.g. `x =~ /b/`)
* `==~` true if the entire text matches a pattern (e.g. `x ==~ /[Bb]ob/`)
[float]
[[painless-control-flow]]
=== Control flow
Java's https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html[control flow statements] are supported, with the exception