Thanks Josh! That makes a lot of sense. I didn't see that github discussion when I was googling this.
Patrick On Friday, July 10, 2015 at 8:10:14 AM UTC-7, Josh Langsfeld wrote: > > You can see the discussion about changing the deprecation suggestion here: > https://github.com/JuliaLang/julia/pull/11369 > > I think people liked it because it's a bit of an abuse of terminology to > call the [a:b;] form 'concatenation' when there is only one object being > put into the array. The 'collect' form is semantically closer to converting > the range into an array rather than concatenating it. It is just a > suggestion though and I believe [a:b;] will continue to work fine for the > foreseeable future. Another option that works is 'convert(Vector{Int}, > 1:5)'. All three call the 'vcat' function under the hood. > > [c;d] should never have given a deprecation warning because that was > always the proper syntax for vertical concatenation of two array-like > objects. It was only the meaning of the comma and wrapping a single object > in brackets that was changed. At least one semicolon is needed so that the > parser knows to call vcat rather than vector creation. Any further > superfluous ones are just ignored by the parser. > > On Thursday, July 9, 2015 at 11:19:53 PM UTC-4, Patrick Belliveau wrote: >> >> Hi, >> I'm running Julia Version 0.4.0-dev+5852. I ran some old code >> yesterday that used the [a:b] syntax (where a and b are integers). Executing >> >> array = [a:b] >> >> gives the deprecation warning >> >> WARNING: [a] concatenation is deprecated; use collect(a) instead. >> >> Neither array = [3:5;], nor array = collect(3:5) produce any warnings and >> they seem to give the same output. The deprecation warning would seem to >> suggest that the collect(a:b) syntax is preferable to [a:b;]. I'm wondering >> why that's the case? On a related note, for vectors c and d, array = [c;d] >> doesn't give a deprecation warning suggesting the array = [c;d;] syntax, >> which I believe it did on older 0.4.0-dev builds. What is the significance >> of the trailing semicolon? >> >> Thanks very much, Patrick >> >> >>
