ios - Swift enum operator overloading -


I have defined an enum, and I want to use it as a key for a dictionary when I I am trying to use the value as a key, then I get an error about anmut, which is the dictionaryIndex & lt; Constants.PieceValue, Array & lt; String & gt; & Gt; , where constants. PieceValue is an enum that looks like this:

  public enum pseuway: int {case blank = 0, wking = 16, wquan = 15, WRK = 14, W.Bishap = 13, Wkrite = 12, WPOn = 11, beating = 26, Bequinn = 25, brow = 24, BBShop = 23, BK NIGHT = 22, BPN = 21}  < / Pre> 

I read some threads, but I got no clear answer. I have also declared the operator overloading function for the enum outside the constants category.

  func == (left: constant. Pse.value, right: constant. ਪੀਸਵੀਅਲ) - & gt; Boole {return int (left) == int (right)}  

This is the line which encodes complaint:

  self.label1.text = Constants.pieceMapping [self.pieceValue] [0]  

Constants.pieceMapping contains the following types: dictionary & lt; PeaceWell, Array & lt; String & gt; & Gt;

 < Code> Constants.pieceMapping [self.pieceValue]  

the array is the type. In order to reach that array, you must first open the alternative, either firmly opening it:

Or use alternate binding in a safe way:

  if array = constants.pieceMapping [Constants.PieceValue.BPawn] {Allow = array [0]}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -