Product SiteDocumentation Site

Chapter 11. Expressions Dealing with Types

11.1. Instance-of Expressions
11.2. Treat Expressions
11.3. Castable Expressions
11.4. Cast Expressions
11.5. Typeswitch Expressions
We have already introduced the sequence type syntax. It is now time to introduce the expressions that deal with types.

11.1. Instance-of Expressions

A quick glimpse on this expression was already given. An instance expression can be used to tell whether a sequence matches a given sequence type, like in Java.
Example 11.1. Instance of expression.
1 instance of integer,
1 instance of string,
"foo" instance of string,
{ "foo" : "bar" } instance of object,
({ "foo" : "bar" }, { "bar" : "foo" })
    instance of json-item+,
[ 1, 2, 3 ] instance of array?,
() instance of ()
Results:
true
false
true
true
true
true
true