Skip to content

class C(x: R) NOT same as class C(private val x: R) #568

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion cheatsheets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ languages: [ba, fr, ja, 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 |
| <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(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 |
Expand Down