We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d88d63 commit ce7f775Copy full SHA for ce7f775
core/stdlib/std.ncl
@@ -2148,6 +2148,28 @@
2148
"%%
2149
= fun field r => r."%{field}",
2150
2151
+ getor
2152
+ : forall a. String -> a -> { _ : a } -> a
2153
+ | doc m%%"
2154
+ Returns the field of a record with given name or default value,
2155
+ if there is no such field.
2156
+
2157
+ # Examples
2158
2159
+ ```nickel
2160
+ std.record.get "tree" 3 { one = 1, two = 2 } =>
2161
+ 3
2162
2163
+ std.record.get "one" 11 { one = 1, two = 2 } =>
2164
+ 1
2165
+ ```
2166
+ "%%
2167
+ = fun field default_value r =>
2168
+ if std.record.has_field field r then
2169
+ std.record.get field r
2170
+ else
2171
+ default_value,
2172
2173
insert
2174
: forall a. String -> a -> { _ : a } -> { _ : a }
2175
| doc m%%"
0 commit comments