From 06477f895adcd9d51c6dd748c4e0fded2fd5f45a Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Wed, 6 Nov 2024 11:33:27 -0300 Subject: [PATCH] Add type restrictions to Levenshtein 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