diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-16 05:51:26 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-16 05:51:26 +0000 |
commit | aa674f304d945c6c400bceeef5a8db90f3ee73d0 (patch) | |
tree | baf978076f04d8d73ac079dc3232d8042bf33ed4 /src/library/scala/runtime/RichInt.scala | |
parent | ad775b3239c8dd00b023a2646d663e0d6227cf22 (diff) | |
download | scala-aa674f304d945c6c400bceeef5a8db90f3ee73d0.tar.gz scala-aa674f304d945c6c400bceeef5a8db90f3ee73d0.tar.bz2 scala-aa674f304d945c6c400bceeef5a8db90f3ee73d0.zip |
Added documentation for RichInt.
Contributed by Marc Weil.
Diffstat (limited to 'src/library/scala/runtime/RichInt.scala')
-rw-r--r-- | src/library/scala/runtime/RichInt.scala | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/library/scala/runtime/RichInt.scala b/src/library/scala/runtime/RichInt.scala index c1439669f8..347e8c8e86 100644 --- a/src/library/scala/runtime/RichInt.scala +++ b/src/library/scala/runtime/RichInt.scala @@ -16,23 +16,58 @@ import annotation.bridge // the Int-specific Range class from until/to. final class RichInt(val self: Int) extends ScalaNumberProxy[Int] with RangedProxy[Int] { type ResultWithoutStep = Range + + /** + * @return `true` if this number has no decimal component. Always returns true for `RichInt`. + */ def isWhole() = true + /** + * @param end The final bound of the range to make. + * @return A [[Range]] from `this` up to but not including `end`. + */ def until(end: Int): Range = Range(self, end) + + /** + * @param end The final bound of the range to make. + * @param step The number to increase by for each step of the range. + * @return A [[Range]] from `this` up to but not including `end`. + */ def until(end: Int, step: Int): Range = Range(self, end, step) // @bridge // def until(end: Int): Range with Range.ByOne = new Range(self, end, 1) with Range.ByOne /** like `until`, but includes the last index */ + /** + * @param end The final bound of the range to make. + * @return A [[Range]] from `this` up to and including `end`. + */ def to(end: Int): Range.Inclusive = Range.inclusive(self, end) + + /** + * @param end The final bound of the range to make. + * @param step The number to increase by for each step of the range. + * @return A [[Range]] from `this` up to and including `end`. + */ def to(end: Int, step: Int): Range.Inclusive = Range.inclusive(self, end, step) // @bridge // def to(end: Int): Range with Range.ByOne = new Range.Inclusive(self, end, 1) with Range.ByOne + /** + * @return `this` if `this < that` or `that` otherwise + */ override def min(that: Int): Int = if (self < that) self else that + + /** + * @return `this` if `this > that` or `that` otherwise + */ override def max(that: Int): Int = if (self > that) self else that + + /** + * Computes the absolute value of `this`. + */ override def abs: Int = if (self < 0) -self else self def toBinaryString: String = java.lang.Integer.toBinaryString(self) |