diff --git a/src/spectator/block.cr b/src/spectator/block.cr index ad6a861..5b365a1 100644 --- a/src/spectator/block.cr +++ b/src/spectator/block.cr @@ -16,7 +16,7 @@ module Spectator # The *proc* will be called to evaluate the value of the expression. # The *label* is usually the Crystal code for the *proc*. # It can be nil if it isn't available. - def initialize(@block : -> T, label : Label) + def initialize(@block : -> T, label : Label = nil) super(label) end @@ -24,7 +24,7 @@ module Spectator # The block will be called to evaluate the value of the expression. # The *label* is usually the Crystal code for the *block*. # It can be nil if it isn't available. - def initialize(label : Label, &@block : -> T) + def initialize(label : Label = nil, &@block : -> T) super(label) end diff --git a/src/spectator/value.cr b/src/spectator/value.cr index 9d04871..dd81de7 100644 --- a/src/spectator/value.cr +++ b/src/spectator/value.cr @@ -14,9 +14,16 @@ module Spectator # Creates the value. # Expects the *value* of the expression and a *label* describing it. # The *label* is usually the Crystal code evaluating to the *value*. - # It can be nil if it isn't available. def initialize(@value : T, label : Label) super(label) end + + # Creates the value. + # Expects the *value* of the expression. + # It can be nil if it isn't available. + # A label is generated by calling `#inspect` on the *value*. + def initialize(@value : T) + super(@value.inspect) + end end end