Skip to content

Commit

Permalink
Added old Char#digit? and Char#alpha? with a deprecation warning,…
Browse files Browse the repository at this point in the history
… to ease migration. Updated Changelog.
  • Loading branch information
asterite committed Nov 22, 2016
1 parent b6e4744 commit de680fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,7 +3,10 @@
* **(breaking change)** Removed `ifdef` from the language
* **(breaking change)** Removed `PointerIO`
* **(breaking change)** The `body` property of `HTTP::Request` is now an `IO?` (previously it was `String`). Use `request.body.try(&.gets_to_end)` if you need the entire body as a String.
* **(breaking change)** `Char#digit?` was split into `Char#ascii_number?` and `Char#number?`. The old name is still available and will produce a compile-time warning, but will be removed immediately after 0.20.0.
* **(breaking change)** `Char#alpha?` was split into `Char#ascii_letter?` and `Char#letter?`. The old name is still available and will produce a compile-time warning, but will be removed immediately after 0.20.0.
* **(breaking change)** The `Iterable` module is now generic
* Many `String` and `Char` methods are now unicode-aware, for example `String#downcase`, `String#upcase`, `Char#downcase`, `Char#upcase`, `Char#whitespace?`, etc.
* Added support for HTTP client and server streaming.
* Added support for ARM (thanks @ysbaddaden)
* Added support for AArch64 (thanks @ysbaddaden)
Expand Down
12 changes: 12 additions & 0 deletions src/char.cr
Expand Up @@ -124,6 +124,12 @@ struct Char
ord < 128
end

# DEPRECATED: use `#ascii_number?` or `#number?`. This method will be removed after 0.20.0.
def digit?(base : Int = 10)
{{ puts "Warning: `Char#digit?` is deprecated and will be removed after 0.20.0, use `Char#ascii_number?` or `Char#number?` instead".id }}
ascii_number?(base)
end

# Returns `true` if this char is an ASCII number in specified base.
#
# Base can be from 0 to 36 with digits from '0' to '9' and 'a' to 'z' or 'A' to 'Z'.
Expand Down Expand Up @@ -195,6 +201,12 @@ struct Char
ascii? ? ascii_uppercase? : Unicode.uppercase?(self)
end

# DEPRECATED: use `#ascii_letter?` or `#letter?`. This method will be removed after 0.20.0.
def alpha?
{{ puts "Warning: `Char#alpha?` is deprecated and will be removed after 0.20.0, use `Char#ascii_letter?` or `Char#letter?` instead".id }}
ascii_letter?
end

# Returns `true` if this char is an ASCII letter ('a' to 'z', 'A' to 'Z').
#
# ```
Expand Down

0 comments on commit de680fb

Please sign in to comment.