Skip to content

Add missed isSimilar examples in traits.md. #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions tutorials/tour/traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,20 @@ object TraitsTest extends App {
val p1 = new Point(2, 3)
val p2 = new Point(2, 4)
val p3 = new Point(3, 3)
println(p1.isNotSimilar(p2))
println(p1.isNotSimilar(p3))
val p4 = new Point(2, 3)
println(p1.isSimilar(p2))
println(p1.isSimilar(p3))
// Point's isNotSimilar is defined in Similarity
println(p1.isNotSimilar(2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 2 supposed to be p2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it supposed to illustrate that similarity test fails on 2.isInstanceOf[Point] test !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh, right

println(p1.isNotSimilar(p4))
}
```

Here is the output of the program:

```
false
true
false
true
false
```