Skip to content

Commit

Permalink
Add type restrictions to Levenshtein (crystal-lang#15168)
Browse files Browse the repository at this point in the history
It best documents what happens when no entry is between the tolerance level of distance
  • Loading branch information
beta-ziliani authored and CTC97 committed Nov 9, 2024
1 parent 54d22e7 commit 40580f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/levenshtein.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 40580f1

Please sign in to comment.