Julia: Prefer collect(a:b) over [a:b;] in tests

Created on 22 Sep 2020  路  4Comments  路  Source: JuliaLang/julia

As discussed here the use of [a:b;] is not as natural as collect(a:b) and it might be good to prefer collect in tests.
Here for example:
https://github.com/JuliaLang/julia/blob/46cf572773b05d8f4ab74705b139f7a921227c02/test/sorting.jl#L36

CC @oheil @ericphanson @tpapp

Most helpful comment

I don't personally see a big advantage to collect, and the semicolon notation is widely used (e.g., you see A = [1 2; 3 4] all the time).

All 4 comments

I would also prefer collect, but this may not be worth a PR if we are talking about test code.

I would suggest you wait for the core devs to chime in before investing the effort.

I don't personally see a big advantage to collect, and the semicolon notation is widely used (e.g., you see A = [1 2; 3 4] all the time).

Of course the syntax for hvcat is widely used and perfectly fine in general, but using it just for collect is a minor style abuse IMO. But not a big deal, this is a matter of taste.

There's no need to go through all the tests and change this. Probably best to leave it to the discretion of the test writer.

Was this page helpful?
0 / 5 - 0 ratings