diff options
| author | Simon Proctor <simon.proctor@zpg.co.uk> | 2019-05-02 14:03:39 +0100 |
|---|---|---|
| committer | Simon Proctor <simon.proctor@zpg.co.uk> | 2019-05-02 14:03:39 +0100 |
| commit | 2df07eb00f757753d1aed8e75f4579f8b54d9de7 (patch) | |
| tree | af26502146b4a0bb77c853798f68a42a2cc1e009 | |
| parent | 17403fe9f2423fea312e57b752ee465ee2ff6931 (diff) | |
| download | perlweeklychallenge-club-2df07eb00f757753d1aed8e75f4579f8b54d9de7.tar.gz perlweeklychallenge-club-2df07eb00f757753d1aed8e75f4579f8b54d9de7.tar.bz2 perlweeklychallenge-club-2df07eb00f757753d1aed8e75f4579f8b54d9de7.zip | |
Handle a case where the range start and finish differ by one
| -rwxr-xr-x | challenge-006/simon-proctor/perl6/ch-1.p6 | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/challenge-006/simon-proctor/perl6/ch-1.p6 b/challenge-006/simon-proctor/perl6/ch-1.p6 index 00dca1a540..6d3c0f0715 100755 --- a/challenge-006/simon-proctor/perl6/ch-1.p6 +++ b/challenge-006/simon-proctor/perl6/ch-1.p6 @@ -12,7 +12,10 @@ class GrowableRange { method grow() { $!max++; return self } - method gist() { $!min == $!max ?? $!min.Str !! "{$!min}-{$!max}" } + method gist() { $!min == $!max ?? + $!min.Str !! $!max == $!min+1 ?? + "{$!min},{$!max}" + !! "{$!min}-{$!max}" } method Str() { self.gist } } |
