Is there a better way to assign two variable to two others conditionally? I wrote this code, but it feels like it could be a bit more elegant:

Relevant code only:

GameObject newBall;
GameObject pathBall;
if (tag.Equals(pathBallTagName))
{
    newBall = other.gameObject;
    pathBall = gameObject;
}
else
{
    newBall = gameObject;
    pathBall = other.gameObject;
}


Entire .cs file:

using UnityEngine;
using System.Collections;
using BallDelegate;

public class BallCollider : MonoBehaviour {

    public Spline mySpline;
    private SplineController mySplineController;

    public AllBallManager abm;

    public string pathBallTagName = "PathBalls";
    public string ballTagEnd = "Balls";

    public BoxCollider front;
    public BoxCollider back;
    public BoxCollider spawnArea;

    public string frontName = "BallBox Front";
    public string backName = "BallBox Back";

    public bool isInSpawn = true;

    void Start() {
        mySplineController = GetComponent&lt;SplineController&gt; ();
        BoxCollider[] frontBack = GetComponentsInChildren&lt;BoxCollider&gt; ();
        foreach (BoxCollider bc in frontBack)
            if (bc != null) {
                if (bc.name.Equals (frontName))
                    front = bc;
                else if (bc != null &amp;&amp; bc.name.Equals (backName))
                    back = bc;
            }

    }

    void OnTriggerEnter(Collider other) {
        if (mySplineController)
        {
            mySplineController.go = true;
            if (mySpline)
                mySplineController.gravSpline = mySplineController.currentSpline = mySpline;
        }
        if (other == spawnArea) {
            isInSpawn = true;
        }
        else if (!isInSpawn) {
            BallDelegateCS bd = other.gameObject.GetComponent&lt;BallDelegateCS&gt;();
            if (bd) // only balls, no other game objects
            {
                GameObject newBall;
                GameObject pathBall;
                if (tag.Equals(pathBallTagName))
                {
                    newBall = other.gameObject;
                    pathBall = gameObject;
                }
                else
                {
                    newBall = gameObject;
                    pathBall = other.gameObject;
                }
                while (newBall.transform.parent)
                    newBall = newBall.transform.parent.gameObject; // make sure we don't get BallBall
                abm.MakeWayFor(newBall, pathBall);
            }
        }
    }

    void OnTriggerExit(Collider other) {
        if (other == spawnArea) {
            isInSpawn = false;
        }

    }
}
One alternative, note how we must store the bool result to ensure identical semantics (otherwise you risk calling tag.Equals twice... which in addition to performance considerations might change its result between calls or have side effects!)

bool swap = tag.Equals(pathBallTagName);
GameObject newBall = swap ? other.gameObject : gameObject;
GameObject pathBall = swap ? gameObject : other.gameObject;


Alternatively one could implement a Swap function elsewhere:

GameObject newBall = other.gameObject;
GameObject pathBall = gameObject;
if (tag.Equals(pathBallTagName)) Swap (ref newBall, ref pathBall);