Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created December 10, 2011 07:38
Show Gist options
  • Select an option

  • Save chanwit/1454786 to your computer and use it in GitHub Desktop.

Select an option

Save chanwit/1454786 to your computer and use it in GitHub Desktop.
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()
@wingyplus
Copy link

แล้ว constructor มันไม่ต้องเขียนอะไรเหรอครับ

@chanwit
Copy link
Author

chanwit commented Dec 10, 2011

อันนี้เป็น default construct (ปกติมันจะสร้างให้) เขียนให้เห็นเพื่อจะได้เข้าใจ syntax หน่ะ
เช่น super(); ไม่ได้เป็น statement แบบ Java แต่เป็น construct ที่ควรจะอยู่นอก block

@wingyplus
Copy link

อ่อ ครับ เมื่้อกี้เห็นมันใส่ parameter ตรง new A(x) เข้ามาเลยงงว่าตรง constructor ไม่ต้องใส่ให้เหมือนกันเหรอ

@chanwit
Copy link
Author

chanwit commented Dec 10, 2011

เมื่อกี้เขียนผิด

@wingyplus
Copy link

มันส่งค่าให้ super นี้ส่งเหมือน java เลยมั้ยครับ

@chanwit
Copy link
Author

chanwit commented Dec 10, 2011

ตรงนี้ เหมือน แต่ syntax ดีกว่าตรงที่จะทำให้วาง super ผิดที่ไม่ได้
แต่มีเรื่อง constructor redirection ที่ต่างออกมาหน่อย ยังไม่ได้ลองทำ grammar เลยยังไม่เข้าใจ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment