Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not only in one line but also you don't need to wrap your function argument with a class instantiation, you can just pass the integer into the function you are calling and the compiler takes care of the rest.

And that is a problem with many class based languages, that a class can't work as a primitive, compare Java's int vs Integer.

    program TestType;
    type age = 0..150;
    
    procedure test(age:age);
    begin
      writeln(age);
    end;
    
    begin
     test(100);
     test(200);
    end.


Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: