From 07693aa36715be95b097ece0b67fc4efb5ae87e6 Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Mon, 19 Jul 2021 18:02:34 -0300 Subject: [PATCH] fixing doc of step --- src/char.cr | 7 +++++++ src/number.cr | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/char.cr b/src/char.cr index 64166dfb9c25..f081318335df 100644 --- a/src/char.cr +++ b/src/char.cr @@ -122,6 +122,12 @@ struct Char self - other end + # Performs a `#step` in the direction of the _limit_. For instance: + # + # ``` + # 'd'.step(to: 'a').to_a # => ['d', 'c', 'b', 'a'] + # 'a'.step(to: 'd').to_a # => ['a', 'b', 'c', 'd'] + # ``` def step(*, to limit = nil, exclusive : Bool = false, &) if limit direction = limit <=> self @@ -133,6 +139,7 @@ struct Char end end + # :ditto: def step(*, to limit = nil, exclusive : Bool = false) if limit direction = limit <=> self diff --git a/src/number.cr b/src/number.cr index 096e1f99fd77..333c884185d8 100644 --- a/src/number.cr +++ b/src/number.cr @@ -118,7 +118,12 @@ struct Number %array end - # :ditto: + # Performs a `#step` in the direction of the _limit_. For instance: + # + # ``` + # 10.step(to: 5).to_a # => [10, 9, 8, 7, 6, 5] + # 5.step(to: 10).to_a # => [5, 6, 7, 8, 9, 10] + # ``` def step(*, to limit = nil, exclusive : Bool = false, &) : Nil if limit direction = limit <=> self