Created
December 10, 2011 07:38
-
-
Save chanwit/1454786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a() => return new A(); | |
| class A extends Object { | |
| Object _o; | |
| A() : super() { } | |
| Object get o() => return this._o; | |
| set o(Object value) => this._o = value; | |
| } | |
| a() |
Author
อันนี้เป็น default construct (ปกติมันจะสร้างให้) เขียนให้เห็นเพื่อจะได้เข้าใจ syntax หน่ะ
เช่น super(); ไม่ได้เป็น statement แบบ Java แต่เป็น construct ที่ควรจะอยู่นอก block
อ่อ ครับ เมื่้อกี้เห็นมันใส่ parameter ตรง new A(x) เข้ามาเลยงงว่าตรง constructor ไม่ต้องใส่ให้เหมือนกันเหรอ
Author
เมื่อกี้เขียนผิด
มันส่งค่าให้ super นี้ส่งเหมือน java เลยมั้ยครับ
Author
ตรงนี้ เหมือน แต่ syntax ดีกว่าตรงที่จะทำให้วาง super ผิดที่ไม่ได้
แต่มีเรื่อง constructor redirection ที่ต่างออกมาหน่อย ยังไม่ได้ลองทำ grammar เลยยังไม่เข้าใจ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
แล้ว constructor มันไม่ต้องเขียนอะไรเหรอครับ