Water 5-Common Data Types-Generic Object and Collection
method get
Contract
Return typewob
Parameter keyDefault valueType
keyreq
lookupfalseboolean
returns"first"string
if_missing"return"string
defaultfalseboolean
Water Contract
<method get
  key       =req
  lookup    =false=boolean
  returns   ="first"
  if_missing="return"
  default   =false/>
Get provides a way to access values of fields via a method call. Most of the time you access a field you can do simply:
<class boat color="blue"/>
boat.color
"blue"
If the field name is in a variable and you want it to be dynamically computed, you can do something like:
boat.<get "co".<join "lor"/>/>
"blue"
which is equivalent to:
boat.<get "color"/>"blue"
Note that all the arguments to get are of execution kind ekind.code . Normally, get looks for the field only in the subject and if it doesn't find it in the subject, it returns false . But you can have get do a lookup into the parents of the subject by supplying an argument of lookup=true like so:
boat.<get "color" lookup=true/>
"blue"
in which case the parent of boat , and its parent will also be searched. The closest parent to the subject that has the passed in field key will supply the value of the call to get . The above call to get behaves just like: boat.color The default value of the lookup argument is false . Th _subject to get defaults to the local environment:
<set aaa=333>  
   <get "aaa"/>  
  </>
333

a wob
Parameter keyDefault valueType
if_missing"return"string
If the key can not be found, return this value.

<thing/>.<get "x" if_missing=0/>
0
<thing/>.<get "x" if_missing=error/>
error
a wob
if_missing=false
The default value. If the key can not be found, it returns false.
a wob
if_missing=error
An error is thrown rather than returning a value.

If you want to get a vector of ALL the values of a particular field in all the ancestors, call get with returns="all" like so:
<<thing color="red"/> color="white"/>.
     <get "color" returns="all"/>
<vector "white"/>
Here we are creating a parent object with a color of "red" and a child object of that parent with a color of white. The returned vector is <vector "white" "red"/> where the order of the elements is the "closest value to _subject is first", in this case "white" . If you use returns="all" and lookup="false" then you will get a vector of one value, the value of the field in _subject