lunduniversity / introprog

Teaching material for "Introduction to Programming using Scala" at Lund University, LTH. http://cs.lth.se/pgk/
141 stars 167 forks source link

Removed "new" keyword from w04-objects-exercise.tex #753

Closed OlofBen closed 9 months ago

OlofBen commented 9 months ago

New should not be used in Scala, except for in factory methods right?

bjornregnell commented 9 months ago

Well "should" is a bit strong. It's rather that you can skip it if you want.

bjornregnell commented 9 months ago

I'm hesitating if we should keep new or not in this exercise as it makes the allocation explicit and it is a prequel to next week's theme on classes. What do you think? We could keep new here and add a comment or so that new can be skipped.

OlofBen commented 9 months ago

You've got a point. However, the students have not seen the "new" keyword yet, so I think it can be a bit confusing for a new student. Removing new makes the syntax similar to initializing an Integer, which is more familiar for new students.

bjornregnell commented 9 months ago

Actually they have seen new - there is a part during the lectures about classes as a prequel in week objects before next week on classes, and the see with and without new etc, and we talk about allocation on the heap and draw clouds etc.

OlofBen commented 9 months ago

Oh, I missed that. Then I think we should leave it as it is.

bjornregnell commented 9 months ago

Ok great. It is good if tutors explain what new means during exercises.