From 40580f1bb6cf1f5a026a417aff061567411954bb Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Thu, 7 Nov 2024 16:46:28 -0300 Subject: [PATCH] Add type restrictions to Levenshtein (#15168) It best documents what happens when no entry is between the tolerance level of distance --- src/levenshtein.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/levenshtein.cr b/src/levenshtein.cr index e890d59c90ef..01ad1bc40784 100644 --- a/src/levenshtein.cr +++ b/src/levenshtein.cr @@ -139,7 +139,7 @@ module Levenshtein # end # best_match # => "ello" # ``` - def self.find(name, tolerance = nil, &) + def self.find(name, tolerance = nil, &) : String? Finder.find(name, tolerance) do |sn| yield sn end @@ -154,7 +154,7 @@ module Levenshtein # Levenshtein.find("hello", ["hullo", "hel", "hall", "hell"], 2) # => "hullo" # Levenshtein.find("hello", ["hurlo", "hel", "hall"], 1) # => nil # ``` - def self.find(name, all_names, tolerance = nil) + def self.find(name, all_names, tolerance = nil) : String? Finder.find(name, all_names, tolerance) end end