[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table construction: key is string with dash
- From: "Pierre Chapuis" <catwell@...>
- Date: Wed, 3 Sep 2014 14:19:41 +0200
>> I can make a function call as
>> svg.rectangle{ width=100, height=42, fill="black" }
>> But attributes with a dash require the ugly syntax
>> svg.rectangle{ fill="black", ["stroke-width"]=1.337 }
> My solution has usually been to write it as stroke_width and then
> gsub('_', '-') before writing.
For what it's worth this also happens with things like
HTTP headers. My solution, in code, is to agree to use the
"ugly" syntax and go on with my life.
If you never have underscores in key names, the above
solution can also work pretty well.