Skip to content

Commit

Permalink
Enhance docs for Int#downto (#14176)
Browse files Browse the repository at this point in the history
Co-authored-by: George Dietrich <george@dietrich.app>
  • Loading branch information
jkthorne and Blacksmoke16 committed Jan 12, 2024
1 parent 79b6e73 commit 7867cd8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/int.cr
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,20 @@ struct Int
end

# Calls the given block with each integer value from self down to `to`.
#
# ```
# 3.downto(1) do |i|
# puts i
# end
# ```
#
# Prints:
#
# ```text
# 3
# 2
# 1
# ```
def downto(to, &block : self ->) : Nil
return unless self >= to
x = self
Expand Down

0 comments on commit 7867cd8

Please sign in to comment.