How is this always the same outcome?? Caution: contains sex! ;)

Hey Guys, I’m running in to a weird problem that I’m sure is a simple solution but for some reason when I always get the “NoGender = 0” value returned in my enum even tho all the other variables in my Sex class return appropriately. Have a look at the constructor then see the output below:

public enum Gender {
	NoGender = 0,
	Male = 1,
	Female = 2,
	COUNT = 3
}	

public class Sex {
	public Gender gender;
	public string name;
	public string possesiveName;
	public string thirdPersonName;
	public string youngName;
	public string grownName;
	public Vector3 sexScale;
	public int[] hairIndexes;
	
	public Sex(Gender gender) {
		if(gender == SexData.Gender.Male){
			gender 				= 	SexData.Gender.Male;
			name				=	"Male";
			possesiveName		=	"his";
			thirdPersonName		=	"he";
			youngName			=	"boy";
			grownName			=	"man";
		}
		else if(gender == SexData.Gender.Female){
			gender				=	SexData.Gender.Female;
			name				=	"Female";
			possesiveName		=	"her";
			thirdPersonName		=	"she";
			youngName			=	"girl";
			grownName			=	"woman";
			sexScale			=	new Vector3(.8f, .9f, .8f);
		}
		else{
			gender = SexData.Gender.NoGender;
			name = "No Gender";
		}	
	}
}

Meanwhile; In another script…

int temp = UnityEngine.Random.Range( (int)SexData.Gender.Male, (int)SexData.Gender.COUNT );
characterSex = new SexData.Sex((SexData.Gender)temp);
Debug.Log(characterSex.gender + " = " + (int)characterSex.gender + " aka " + characterSex.name);

Will always output in the console: “NoGender = 0 aka Female” or “NoGender = 0 aka Male”
In short, characterSex.gender always returns the same while characterSex.name (set in the constructor) returns appropriately!! I’m lost, thanks for the help!

You’re assigning to the gender variable passed as a parameter.

You need

if(gender == SexData.Gender.Male){
    this.gender = SexData.Gender.Male;