Enum comparison C#

Can anyone explain why this is not working?

	void OnTriggerEnter2D(Collider2D other){
		if (other.CompareTag ("Boundary")) {
			Debug.Log("Before " + direction);
			if ((int)direction == (int)Direction.RIGHT)
				direction = Direction.LEFT;
			if ((int)direction == (int)Direction.LEFT)
				direction = Direction.RIGHT;
			Debug.Log("After " + direction);
		}
	}

This is what I am getting on the Console

64253-console.png

it’s doing exactly what you told it to.

you need to use an else if instead of the second if because after you set it to left, you’re immediately setting it back to right.

there’s no need to cast them to int for the comparison if they’re both the same type.