diff --git a/_tour/traits.md b/_tour/traits.md index 464ad1b4f0..a71bd193b1 100644 --- a/_tour/traits.md +++ b/_tour/traits.md @@ -12,7 +12,7 @@ prerequisite-knowledge: expressions, classes, generics, objects, companion-objec redirect_from: "/tutorials/tour/traits.html" --- -Traits are used to share interfaces and fields between classes. They are similar to Java 8's interfaces. Classes and objects can extend traits but traits cannot be instantiated and therefore have no parameters. +Traits are used to share interfaces and fields between classes. They are similar to Java 8's interfaces. Classes and objects can extend traits, but traits cannot be instantiated and therefore have no parameters. ## Defining a trait A minimal trait is simply the keyword `trait` and an identifier: @@ -29,7 +29,7 @@ trait Iterator[A] { } ``` -Extending the `trait Iterator[A]` requires a type `A` and implementations of the methods `hasNext` and `next`. +Extending the `trait Iterator[A]` requires a type `A`, and implementations of the methods `hasNext` and `next`. ## Using traits Use the `extends` keyword to extend a trait. Then implement any abstract members of the trait using the `override` keyword: @@ -78,4 +78,4 @@ animals.append(dog) animals.append(cat) animals.foreach(pet => println(pet.name)) // Prints Harry Sally ``` -The `trait Pet` has an abstract field `name` which gets implemented by Cat and Dog in their constructors. On the last line, we call `pet.name` which must be implemented in any subtype of the trait `Pet`. +The `trait Pet` has an abstract field `name` that gets implemented by Cat and Dog in their constructors. On the last line, we call `pet.name`, which must be implemented in any subtype of the trait `Pet`.