Logo

Programming-Idioms

History of Idiom 5 > diff from v12 to v13

Edit summary for version 13 by :

Version 12

2015-08-22, 22:54:02

Version 13

2015-08-27, 19:04:59

Idiom #5 Create a 2D Point data structure

Declare a container type for two floating-point numbers x and y

Idiom #5 Create a 2D Point data structure

Declare a container type for two floating-point numbers x and y

Code
Point = Struct.new(:x, :y)
Code
Point = Struct.new(:x, :y)
Comments bubble
init like this : Point.new(1.0,1.0)
Comments bubble
Instantiate like this : Point.new(1.0,1.0)
Doc URL
http://www.ruby-doc.org/core-2.1.0/Struct.html
Doc URL
http://www.ruby-doc.org/core-2.1.0/Struct.html