Collections: Difference between revisions

no edit summary
m (minor update for delete of item in prolog list)
No edit summary
Line 264:
* A Map object is serializable into JSON only if it uses one of the following data types as a key.
Boolean, Date, DateTime, Decimal, Double, Enum, Id, Integer, Long, String, Time
 
=={{header|Arturo}}==
 
===Array===
 
<lang arturo>// initialize array
array #("one" 2 "three" "four")
 
// add an element to the array
array array + #(5)
 
print array</lang>
 
{{out}}
 
<pre>#("one" 2 "three" "four" 5)</pre>
 
===Dictionary===
 
<lang arturo>// initialize dictionary
dict #{
name "john"
surname "doe"
age 33
 
preferedFood #("fruit" "pizza")
}
 
// add an element to the dictionary
dict dict + #{ country "Spain" }
 
print dict</lang>
 
{{out}}
 
<pre>#{
age 33
country "Spain"
name "john"
preferedFood #(
"fruit"
"pizza"
)
surname "doe"
}</pre>
 
===Class===
 
<lang arturo>// define a new class-type dictionary
Person #{
name ""
surname ""
 
init [n,s]{
name n
surname s
}
 
sayHello {
print "Hello " + name + "!"
}
}
 
// create a new Person object and initialize it
person $(new ~Person "John" "Doe")
 
// use an inner function
!person.sayHello
 
log person</lang>
 
{{out}}
 
<pre>Hello John!
#{
init <function: 0x1057223E0>
name "John"
sayHello <function: 0x105722440>
surname "Doe"
}</pre>
 
=={{header|AutoHotkey}}==
1,532

edits