How do I define an array of anonymous objects in CoffeeScript? Is this possible at all, using the YAML syntax?
I know that having an array of named objects is quite easy:
items:[
item1:
name1:value1
item2:
name:value2
]
However, it would be a bit trickier, if those two objects had no names
Simple -- place a comma by itself in a column lower than that in which you define your objects.
a = [
nameA1: valueA1
nameA2: valueA2
nameA3: valueA3
,
nameB1: valueB1
nameB2: valueB2
nameB3: valueB3
]
Will become:
var a;
a = [
{
nameA1: valueA1,
nameA2: valueA2,
nameA3: valueA3
}, {
nameB1: valueB1,
nameB2: valueB2,
nameB3: valueB3
}
];
You can also add a coma between each object:
items:[
item1:
name1:value1
,
item2:
name:value2
]
you can't:
this is some tricks:
items:[
(name:"value1")
(name:"value2")
]
another
items:[
true && name:"value1"
true && name:"value2"
]
this is the best:
items:[
{name:"value1"}
{name:"value2"}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With