Skip to content

Commit

Permalink
Merge pull request #9419 from koterpillar/patch-1
Browse files Browse the repository at this point in the history
Enumeration documentation: remove nested class shadowing in "override" position
  • Loading branch information
dwijnand committed Jan 13, 2021
2 parents f2d2e6e + a398b9b commit d057f62
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/library/scala/Enumeration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ import scala.util.matching.Regex
* @example {{{
* // Example of adding attributes to an enumeration by extending the Enumeration.Val class
* object Planet extends Enumeration {
* protected case class Val(mass: Double, radius: Double) extends super.Val {
* protected case class PlanetVal(mass: Double, radius: Double) extends super.Val {
* def surfaceGravity: Double = Planet.G * mass / (radius * radius)
* def surfaceWeight(otherMass: Double): Double = otherMass * surfaceGravity
* }
* implicit def valueToPlanetVal(x: Value): Val = x.asInstanceOf[Val]
* implicit def valueToPlanetVal(x: Value): PlanetVal = x.asInstanceOf[PlanetVal]
*
* val G: Double = 6.67300E-11
* val Mercury = Val(3.303e+23, 2.4397e6)
* val Venus = Val(4.869e+24, 6.0518e6)
* val Earth = Val(5.976e+24, 6.37814e6)
* val Mars = Val(6.421e+23, 3.3972e6)
* val Jupiter = Val(1.9e+27, 7.1492e7)
* val Saturn = Val(5.688e+26, 6.0268e7)
* val Uranus = Val(8.686e+25, 2.5559e7)
* val Neptune = Val(1.024e+26, 2.4746e7)
* val Mercury = PlanetVal(3.303e+23, 2.4397e6)
* val Venus = PlanetVal(4.869e+24, 6.0518e6)
* val Earth = PlanetVal(5.976e+24, 6.37814e6)
* val Mars = PlanetVal(6.421e+23, 3.3972e6)
* val Jupiter = PlanetVal(1.9e+27, 7.1492e7)
* val Saturn = PlanetVal(5.688e+26, 6.0268e7)
* val Uranus = PlanetVal(8.686e+25, 2.5559e7)
* val Neptune = PlanetVal(1.024e+26, 2.4746e7)
* }
*
* println(Planet.values.filter(_.radius > 7.0e6))
Expand Down

0 comments on commit d057f62

Please sign in to comment.