Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1009170 // Test Alt (union type)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1483L/10K/35K).

!7

p {
  final Alt<S, Int> a = alt1('Hello);
  final Alt<S, Int> b = alt2(123);
  
  assertTrue(a.isA());
  assertFalse(a.isB());
  assertFalse(b.isA());
  assertTrue(b.isB());
  
  assertEqualsVerbose('Hello, a.a());
  assertFail(r { a.b() });
  
  assertEqualsVerbose(123, b.b());
  assertFail(r { b.a() });
  
  print("OK!");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009170
Snippet name: Test Alt (union type)
Eternal ID of this version: #1009170/1
Text MD5: b30adcaa488173e6c1037e62a86765a4
Transpilation MD5: a310835964fa0606f9bc84eff5a6a5fe
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-12 13:26:45
Source code size: 349 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 422 / 495
Referenced in: [show references]