5. public class AreaCalculator
{
public double Area(Rectangle[] shapes)
{
double area = 0;
foreach (var shape in shapes)
{
area += shape.Width*shape.Height;
}
return area;
}
}
6. public double Area(object[] shapes)
{
double area = 0;
foreach (var shape in shapes)
{
if (shape is Rectangle)
{
Rectangle rectangle = (Rectangle) shape;
area += rectangle.Width*rectangle.Height;
}
else
{
Circle circle = (Circle)shape;
area += circle.Radius * circle.Radius * Math.PI;
}
}
return area;
}
15. data Shape = Circle Float | Rectangle Float Float
area :: Shape -> Float
area (Circle r) = pi * r * r
area (Rectangle width height) = width * height
sum $ map area [(Circle 5), (Rectangle 2 3), (Circle 7)]
53. If you want to know more
• Have a look at work Unity3D does https://unity3d.com/unity/
features/job-system-ECS
• Mike Acton @ CppCon 2014 https://www.youtube.com/watch?
v=rX0ItVEVjHc
• Catherine West @ Rust Conf 2018 https://www.youtube.com/
watch?v=aKLntZcp27M
• ECS Lab Discord Server https://discord.gg/eCpyZSg