Update page 'Future P# Versions'
@@ -8,20 +8,18 @@ This document describes an ideas for future versions of P# language specificatio
|
|||||||
### Data Structures
|
### Data Structures
|
||||||
A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. Data structures can be declared in P# using the following syntax:
|
A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. Data structures can be declared in P# using the following syntax:
|
||||||
|
|
||||||
<%
|
struct data {
|
||||||
struct data {
|
string fname;
|
||||||
string fname;
|
string lname;
|
||||||
string lname;
|
int age;
|
||||||
int age;
|
} $person1, $person2;
|
||||||
} $person1, $person2;
|
struct data $person3;
|
||||||
struct data $person3;
|
|
||||||
|
|
||||||
$person1.fname = 'Martin';
|
$person1.fname = 'Martin';
|
||||||
$person1.lname = 'Smith';
|
$person1.lname = 'Smith';
|
||||||
$person1.age = 27;
|
$person1.age = 27;
|
||||||
|
|
||||||
$person2 = {fname => 'Andrew', lname => 'Smith', age => 22};
|
$person2 = {fname => 'Andrew', lname => 'Smith', age => 22};
|
||||||
%>
|
|
||||||
|
|
||||||
Structure members can be access by using a dot operator (.). The arrow operator cannot be used because a structure is not an object.
|
Structure members can be access by using a dot operator (.). The arrow operator cannot be used because a structure is not an object.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user