That's right. '[]' for collecting should be replaced with 'collect'. But in your case you shouldn't have used '[]' in the first place :)
It seems that it is very common for people to collect ranges into arrays, but it is rare that you actually need to. The best approach is to *not* collect, and then see if it works the way you intend it to. On Monday, April 11, 2016 at 12:15:31 PM UTC+2, Fred wrote: > > Thank you for this explanation DNF ! It is the first time I use collect and > the reason why I used it was an error message suggesting that I should use > it :) maybe because of my first mistake to use []. > > Le dimanche 10 avril 2016 23:30:10 UTC+2, DNF a écrit : >> >> The big error you made originally is calling collect in every iteration >> of the loop. Just deleting collect speeds things up by 100x. The lesson >> is that you should (almost) never use collect. >> >> The other lesson is: don't do [1:0.1:10]. It makes your code slower, and >> very soon your it will stop working correctly. Just delete []. >> >
