Entry 2919

Some generics code to test the ooc lexer

   

Submitted by anonymous on Jan. 4, 2010 at 5:32 p.m.
Language: Ooc. Code size: 210 bytes.

print: func <T> (arg: T) {
  if(T == Int) {
    printf("%d\n", arg as Int) // 'as' allows casting
  } else if(T == String) {
    printf("%s\n", arg as String)
  }
}
 
print(1984)
print("George Orwell")

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).