Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -2,3 +2,5 @@
|
|||
Create a compound data type Point(x,y).
|
||||
|
||||
A compound data type is one that holds multiple independent values. See also [[Enumeration]].
|
||||
|
||||
{{Template:See also lists}}
|
||||
|
|
|
|||
2
Task/Compound-data-type/MATLAB/compound-data-type-1.m
Normal file
2
Task/Compound-data-type/MATLAB/compound-data-type-1.m
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
point.x=3;
|
||||
point.y=4;
|
||||
1
Task/Compound-data-type/MATLAB/compound-data-type-2.m
Normal file
1
Task/Compound-data-type/MATLAB/compound-data-type-2.m
Normal file
|
|
@ -0,0 +1 @@
|
|||
point = [3,4];
|
||||
|
|
@ -1,5 +1,15 @@
|
|||
Point = Struct.new(:x,:y)
|
||||
p = Point.new(6,7)
|
||||
p.y=3
|
||||
puts p
|
||||
=> #<struct Point x=6, y=3>
|
||||
pt = Point.new(6,7)
|
||||
puts pt.x #=> 6
|
||||
pt.y = 3
|
||||
puts pt #=> #<struct Point x=6, y=3>
|
||||
|
||||
# The other way of accessing
|
||||
pt = Point[2,3]
|
||||
puts pt[:x] #=> 2
|
||||
pt['y'] = 5
|
||||
puts pt #=> #<struct Point x=2, y=5>
|
||||
|
||||
pt.each_pair{|member, value| puts "#{member} : #{value}"}
|
||||
#=> x : 2
|
||||
#=> y : 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue