Skip to content

Correct differentiation of C(x: R) vs C(val x: R) in cheatsheet #620 #783

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
May 31, 2017
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
4 changes: 2 additions & 2 deletions cheatsheets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ languages: [ba, fr, ja, pl, pt-br]
| <span class="label success">Good</span><br>`val v42 = 42`<br>`Some(3) match {`<br>`` case Some(`v42`) => println("42")``<br>`case _ => println("Not 42")`<br>`}` | "\`v42\`" with backticks is interpreted as the existing val `v42`, and "Not 42" is printed. |
| <span class="label success">Good</span><br>`val UppercaseVal = 42`<br>`Some(3) match {`<br>` case Some(UppercaseVal) => println("42")`<br>` case _ => println("Not 42")`<br>`}` | `UppercaseVal` is treated as an existing val, rather than a new pattern variable, because it starts with an uppercase letter. Thus, the value contained within `UppercaseVal` is checked against `3`, and "Not 42" is printed. |
| <span id="object_orientation" class="h2">object orientation</span> | |
| `class C(x: R)` _same as_ <br>`class C(private val x: R)`<br>`var c = new C(4)` | constructor params - private |
| `class C(val x: R)`<br>`var c = new C(4)`<br>`c.x` | constructor params - public |
| `class C(x: R)` | constructor params - `x` is only available in class body |
| `class C(val x: R)`<br>`var c = new C(4)`<br>`c.x` | constructor params - automatic public member defined |
| `class C(var x: R) {`<br>`assert(x > 0, "positive please")`<br>`var y = x`<br>`val readonly = 5`<br>`private var secret = 1`<br>`def this = this(42)`<br>`}`|<br>constructor is class body<br>declare a public member<br>declare a gettable but not settable member<br>declare a private member<br>alternative constructor|
| `new{ ... }` | anonymous class |
| `abstract class D { ... }` | define an abstract class. (non-createable) |
Expand Down