diff --git a/src/radix/result.cr b/src/radix/result.cr index d58fc0f..ca93480 100644 --- a/src/radix/result.cr +++ b/src/radix/result.cr @@ -61,15 +61,13 @@ module Radix # # => "" # ``` def key : String - return @key if @key - - key = String.build { |io| - @nodes.each do |node| - io << node.key - end - } - - @key = key + @key ||= begin + String.build { |io| + @nodes.each do |node| + io << node.key + end + } + end end # Adjust result information by using the details of the given `Node`.