Compound data type: Difference between revisions
Content deleted Content added
→{{header|Visual Basic .NET}}: Added Vim Script |
|||
Line 1,435: | Line 1,435: | ||
where <code>p</code> is any expression of the defined type. A real application wouldn't be written |
where <code>p</code> is any expression of the defined type. A real application wouldn't be written |
||
this way because pairs of values <code>(x,y)</code> are a common idiom. |
this way because pairs of values <code>(x,y)</code> are a common idiom. |
||
=={{header|Vim Script}}== |
|||
One cannot create new data types in Vim Script. A point could be represented by a dictionary: |
|||
<lang vim>function MakePoint(x, y) " 'Constructor' |
|||
return {"x": a:x, "y": a:y} |
|||
endfunction |
|||
let p1 = MakePoint(3, 2) |
|||
let p2 = MakePoint(-1, -4) |
|||
echon "Point 1: x = " p1.x ", y = " p1.y "\n" |
|||
echon "Point 2: x = " p2.x ", y = " p2.y "\n"</lang> |
|||
{{Out}} |
|||
<pre>Point 1: x = 3, y = 2 |
|||
Point 2: x = -1, y = -4</pre> |
|||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
Line 1,472: | Line 1,489: | ||
End Structure</lang> |
End Structure</lang> |
||
=={{header|XSLT}}== |
=={{header|XSLT}}== |