data = {
:displayrows => 20,
:cols => [
{ :col => "l1" },
{ :col => "l2" },
{ :col => "l3" },
{ :col => "num", :display => true },
{ :col => "sum", :display => true, :conf => { :style => 1, :func => { :method => "sum", :col => "num" } } }
]
... # Lots more
}
data = Dict{Symbol,Any}(
:displayrows => 20,
:cols => [
Dict{Symbol,Any}( :col => "l1" ),
Dict{Symbol,Any}( :col => "l2" ),
Dict{Symbol,Any}( :col => "l3" ),
Dict{Symbol,Any}( :col => "num", :display => true ),
Dict{Symbol,Any}( :col => "sum", :display => true, :conf => Dict{Symbol,Any}( :style => 1,
:func => Dict{Symbol,Any}( :method => "sum", :col => "num" ) ) )
]
... # Lots more
)
Array{Int64,2}( Vector{Int64}( 1,2,3), Vector{Int64}( 4,5,6) )
[ [ 1, 2, 3] [ 4,5,6 ] ]
I have to admit that after having used the new syntax for a while now, I’m not a fan at all. It feels like I’m thrown back to my old C# days…
I’m sure there was an excellent reason for this change, but I couldn’t find the relevant issue on github. If someone has the relevant link handy, I would appreciate the link.
Thanks,
David
If I recall correctly, the two sets of ASCII bracketing operators ([] and {}) were deemed to be more usefully employed for arrays;
We want something as usable for general programming as Python,
We never want to mention types when we don’t feel like it.
Dict{Symbol,Any}( :col => "l1" ) syntax.
I would not claim that something goes wrong here, but my expectation would have been rather: non-verbose syntax where it can be avoided. And i disagree, Dict are not just another data structure.
There is no need to write the type over and over again. You can say
const D = Dict{Symbol, Any}
D(:a => "", :b => 0, ...)
julia> Dict(:a => "", :b => 0)
Dict{Symbol,Any} with 2 entries:
:a => ""
:b => 0
The Dict constructor automatically computes the common parent of the key and value types.
Early adopters shouldn't throw stones... :) But in fact I quite like the new Dict syntax, which seems to be more explicit and readable. Curly braces seem to be gainfully employed elsewhere doing type stuff. And experts can make short cuts, either in Julia or in their editors...
Early adopters shouldn't throw stones... :) But in fact I quite like the new Dict syntax, which seems to be more explicit and readable. Curly braces seem to be gainfully employed elsewhere doing type stuff. And experts can make short cuts, either in Julia or in their editors...I confess I'm a bit puzzled by having to change `[1:10]` to `[1:10...]`, but then again, `collect(1:10)` is more explicit and readable. So I think it's progress.
"Why is [1:10...] a puzzle?"Just that a new user might expect to see or use the ellipsis in its conventional position:[1...10]
[1:10;] is simply a consequence of matrix literal syntax (like [1:10; 11:20]) and gets translated into vcat(1:10). It might be a bit confusing but there's no point in making it a special case