. multimethod
Methods
- .(regexp:RegExp, field:Str)
Get fields of a RegExp. Throws FieldNotFound if field is not one of the allowed values. You should not use this directly. Use "~" and "~~" operators. Parameters
field "options" or "names" Returns
Int for "options". Hash of names/indexes of named groups for "names".Example
/abc/i.options # 1 - case insensitive (C_PCRE_CASELESS) /(?P<name1>abc)/i.names # Name to index Hash: {name1=1}
- .(pa:c_pthread_attr_t, attr:Str)
Get pthread attribute. Currently returns null for unknown attributes. Will throw exceptions in future. Parameters
attr One of: detachstate, guardsize, inheritsched, stacksize.
- .(obj:BasicType, field:Str)
Get BasicType (Int, Arr, Hash, ...) field. Throws FieldNotFound. Automatically called by NGS for syntax
obj.field
Parameters
field Field to get. Currently only "name" and "constructors" are supported. Returns
Str for "name" and MultiMethod for "constructors".Example
Hash.name # String: Hash Hash.constructors # MultiMethod
- .(obj:NormalType, field:Str)
Get NormalType (a type that is typically defined by user) field. Throws FieldNotFound. Automatically called by NGS for syntax
obj.field
Parameters
field Field to get. Currently only "name", "constructors", "parents" and "user" are supported. Returns
Str for "name", MultiMethod for "constructors", Arr for "parents", Any for "user".
- .(obj:NormalTypeInstance, field:Str)
Get NormalType (a type that is typically defined by user) instance field. Throws FieldNotFound. Automatically called by NGS for syntax
obj.field
Returns
AnyExample
type T; t=T(); t.x=1; t.x # 1
- .(x:Any, f:Fun)EXPERIMENTAL Source: stdlib.ngs:696
Undocumented Automatically called by NGS for syntax
x.{ ... }
Returns
f(x)
- .(h:Hash, field:Str) Source: stdlib.ngs:835
Get hash key. Example
h = {"a": 1} h.a # 1, Same as h["a"]
- .(al:ArrLike, s:Str) Source: stdlib.ngs:1927
Return array made of given field of each element of given array. Will throw KeyNotFound if any of the elements does not have the desired field. Use get() to handle missing field differently.
- .(hl:HashLike, k:Any) Source: stdlib.ngs:2043
Get value by key. Throws KeyNotFound. Automatically called by NGS for syntax
your_hashlike.literal_key
Returns
Any
- .(hl:DeprecatedTopLevelHashlike, k:Any) Source: stdlib.ngs:2144
Get value by key. Throws KeyNotFound. Automatically called by NGS for syntax
your_hashlike.literal_key
Returns
Any
- .(t:Type, field:Str) Source: stdlib.ngs:2285
Undocumented Automatically called by NGS for syntax
SUBTYPE_OF_NAMEDINSTANCES.NamedInstances
Example
echo(Color.NamedInstances is Namespace) # true
- .(a:Arr, field:Str) Source: stdlib.ngs:2843
Return array made of given field of each element of given array. Will throw KeyNotFound if any of the elements does not have the desired field. Use get() to handle missing field differently. Returns
ArrExample
[{"x": 1}, {"x": 2}].x # [1, 2] [{"x": 1}, {"y": 2}].x # KeyNotFound exception [{"x": 1}, {"y": 2}].get("x") # [1] - skip [{"x": 1}, {"y": 2}].get("x", null) # [1, null] - use default value
- .(t:Type, field:Str) Source: stdlib.ngs:5419
Undocumented