Create an object/Native demonstration: Difference between revisions
Create an object/Native demonstration (view source)
Revision as of 14:15, 21 November 2023
, 5 months ago→{{header|Wren}}: Changed to Wren S/H
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36, explicit :prototype) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(One intermediate revision by one other user not shown) | |||
Line 10:
If the language supports '''Magic Methods''', then show how these work.
=={{header|
<syntaxhighlight lang="basic256">map mapa
mapa["A"] = 65
Line 27 ⟶ 28:
C
67</pre>
==={{header|FreeBASIC}}===
FB doesn't have Dict natively, but we can implement them via Type▼
<syntaxhighlight lang="freebasic">Type dict▼
m1 As String*1▼
m2 As Integer▼
End Type▼
Dim mapOf(1 To 3) As dict => {("A", 65), ("B", 66), ("C", 67)}▼
For i As Integer = 1 To Ubound(mapOf)▼
Print mapOf(i).m1▼
Print mapOf(i).m2▼
Next i</syntaxhighlight>▼
{{out}}▼
<pre>A▼
65▼
B▼
66▼
C▼
67</pre>▼
=={{header|C++}}==
Line 194 ⟶ 216:
55
["a":1, "b":66]</pre>
▲=={{header|FreeBASIC}}==
▲FB doesn't have Dict natively, but we can implement them via Type
▲<syntaxhighlight lang="freebasic">Type dict
▲ m1 As String*1
▲ m2 As Integer
▲End Type
▲Dim mapOf(1 To 3) As dict => {("A", 65), ("B", 66), ("C", 67)}
▲For i As Integer = 1 To Ubound(mapOf)
▲ Print mapOf(i).m1
▲ Print mapOf(i).m2
▲Next i</syntaxhighlight>
▲{{out}}
▲<pre>A
▲ 65
▲B
▲ 66
▲C
▲ 67</pre>
=={{header|Go}}==
Line 1,405 ⟶ 1,406:
=={{header|Wren}}==
<syntaxhighlight lang="
construct new(map) {
// copy the map so it cannot be mutated from the original reference
|