1

I can't define employee( x:empsex , y:approval ), types are not available.

Trying to use nested enums with struct.

public struct Employee {
public var empsex   : Gender
public var approval : Eligible


public enum Gender : String{
    case male = "MALE"
    case female = "FEMALE"
    public static var genderARR = ["MALE","FEMALE"]
}
public enum Eligible : Int {
    case x = 1 //yes
    case y = 0 //no
    public static var eligibleARR = [1,0]
}
}

public struct Strofempoyestu {
public var empdata : [Employee]=[]


public init (){
    for x in Employee.Gender.genderARR{
        for y in Eemployee.Eligible.eligibleARR{
            empdata.append(Employee( x:empsex , y:approval ))

        }

    }

  }
0

1 Answer 1

4

The point is that you declared genderARR as String instead of Gender and eligibleARR as Int instead of Eligible.

public struct Employee {
    public var empsex   : Gender
    public var approval : Eligible

    public enum Gender : String{
        case male = "MALE"
        case female = "FEMALE"
        public static var genderARR = [male,female]
    }
    public enum Eligible : Int {
        case x = 1 //yes
        case y = 0 //no
        public static var eligibleARR = [x,y]
    }
}

public struct Strofempoyestu {
    public var empdata : [Employee]=[]

    public init (){
        for x in Employee.Gender.genderARR{
            for y in Employee.Eligible.eligibleARR{
                empdata.append(Employee(empsex: x ,approval: y))
            }
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.