Exercise 1: Using foreach in toString

Talaron
Mausschubser
Mausschubser
Beiträge: 85
Registriert: 26. Apr 2012 11:34

Exercise 1: Using foreach in toString

Beitrag von Talaron »

Hi,

are we actually supposed to use the foreach-method in toString? As foreach only applies the given function but doesn't have any return value, I don't see how this would work.

Am I missing something or is there an error in the task? I would have used folding instead of foreach but there is no task to implement it.

//EDIT: Ah okay I've seen the corresponding test using a helper var that stores the results. Not a very nice way to do this but it works, I guess.

ManuelWeiel
Mausschubser
Mausschubser
Beiträge: 72
Registriert: 7. Okt 2014 11:38

Re: Exercise 1: Using foreach in toString

Beitrag von ManuelWeiel »

Yes, using a helper var is probably the easiest way given the operations you should implement.

Antworten

Zurück zu „Archiv“