[cpl] [Tema2] Testul assign-mismatch2

Marius Ungureanu therzok at gmail.com
Tue Dec 1 18:58:08 EET 2015


Salut,

Singura operatie care face conversie implicita de la Int la String
este adunarea.

Marius

2015-12-01 6:40 GMT+02:00 Cristian Hurezeanu via cpl <cpl at cursuri.cs.pub.ro>:
> In testul asta:
>
> class Main inherits IO
>     print Int x :
>         local String s; end;
>         s = if x < 0 then
>                 "Minus " +  -x;
>             else
>                 x;
>             end
>         ;
>         [out s];
>     end;
>
>     main :
>         [print -4];
>         [print 25];
>     end;
> end;
>
> TestRig-ul zice ca trebuie sa arunce IncompatibleOperandsException. Eu vad
> aici doar 3 cazuri posibile:
> 1. s = ... . Ramura then e un string, iar cea else e un int (care se
> converteste implicit la string conform manualului)
> 2. "Minus" + -x. String + int, se converteste implicit la string.
> 3. x < 0. Int < Int
>
> Unde e eroarea mai exact?
>
> _______________________________________________
> cpl mailing list
> cpl at cursuri.cs.pub.ro
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/cpl
>


More information about the cpl mailing list