This language bar is your friend. Select your favorite languages!

Idiom #179 Get center of a rectangle

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

Types
c := CenterPoint(Rect(x1,y1,x2,y2));
Point = Struct.new(:x, :y)

Rect  = Struct.new(:x1, :y1, :x2, :y2) do
  def center  
    Point.new((x1+x2)/2.0, (y1+y2)/2.0)
  end
end

c = Rect.new(0,0,2,5).center

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Bart