lib/rbx/hash.fy in fancy-0.9.0 vs lib/rbx/hash.fy in fancy-0.10.0
- old
+ new
@@ -70,20 +70,30 @@
Sets the default value to be returned from @self for keys not in @self.
If @default_value is a @Block@, use its return value (called with the @Hash@ and a given key).
"""
match default_value {
- case Block -> @default_proc = true
+ case Block ->
+ @got_default_proc = true
+ @default = nil
+ @default_proc = default_value
+ case _ ->
+ @got_default_proc = false
+ @default = default_value
+ @default_proc = nil
}
- @default = default_value
}
def default {
"""
@return Default value for @self.
"""
- @default
+ if: @got_default_proc then: {
+ @default_proc
+ } else: {
+ @default
+ }
}
def default_for: key {
"""
@key Key to be used.