Uses 911K of libraries. Click here for Pure Java version (2124L/11K).
!7 cprint { class A { swappable S x() { ret "a"; } } class B extends A { swappable S x_inner() { ret super.x_base(); } S x_base() { ret "b" + x_inner(); } } start-thread { assertEqualsVerbose("a", new A().x()); assertEqualsVerbose("ba", new B().x()); // override the whole x() method new B c; c.x = () -> "c"; assertEqualsVerbose("c", c.x()); // override the A.x() method while keeping B's added logic c = new B; c.x_inner = () -> "c"; assertEqualsVerbose("bc", c.x()); } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1030769 |
| Snippet name: | swappable + inheritance test [OK] |
| Eternal ID of this version: | #1030769/11 |
| Text MD5: | 36a8a2218004bb5e92c74aadbbccbc0d |
| Transpilation MD5: | 01ab8f3ce60cb9c7c2351d74ac9e5d31 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-03-19 16:13:06 |
| Source code size: | 580 bytes / 27 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 394 / 551 |
| Version history: | 10 change(s) |
| Referenced in: | [show references] |