Logo

Programming-Idioms

History of Idiom 179 > diff from v6 to v7

Edit summary for version 7 by cym13:
New D implementation by user [cym13]

Version 6

2019-01-24, 13:22:41

Version 7

2019-03-19, 16:53:48

Idiom #179 Get center of a rectangle

Return the center c of the rectangle with coördinates(x1,y1,x2,y2)

Idiom #179 Get center of a rectangle

Return the center c of the rectangle with coördinates(x1,y1,x2,y2)

Imports
import std.typecons;
Code
auto c = tuple((x1+x2)/2, (y1+y2)/2);
Comments bubble
Using a tuple, its elements type is infered from the type of its arguments.
Doc URL
https://dlang.org/phobos/std_typecons.html#tuple