setComponent method

Vector2 setComponent(
  1. int index,
  2. double value
)

Implementation

Vector2 setComponent(int index, double value) {
  switch (index) {
    case 0:
      x = value;
      break;
    case 1:
      y = value;
      break;
    default:
      throw "index is out of range: $index";
  }

  return this;
}