precise parameters

Beiträge: 178
Registriert: 10. Apr 2009 16:30

precise parameters

Beitrag von Christian_ »

The exercise states that we should use precise types. Does that mean that we should prevent the use of more general types or just declare them more precise?
for example, I have a Tuple of Int. Should it be possible to add a String and get a new Tuple of Any or should this be prevented?
Omnium rerum principia parva sunt. -Cicero

Beiträge: 61
Registriert: 21. Okt 2013 21:27

Re: precise parameters

Beitrag von imaier »

You should not prevent the use of more general types, but use types that are precise *as possible* (in the context of what you have seen in the lecture about Scala's type system or Java's type system for the second task). In your example, if you add a String to a Tuple of Int, then the result should be a Tuple of Any.


Zurück zu „Archiv“