Skip to content

Commit

Permalink
Add type restrictions to Levenshtein
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 Nov 6, 2024
1 parent 650bb6d commit 06477f8
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 06477f8

Please sign in to comment.