LoginSignup
1
1

More than 5 years have passed since last update.

配列の中の要素の種類数を得る

Posted at

結論から

コード

extension Array where Element: Equatable{
    var categoryCount: Int {
        get{
            var dic = [Element]()
            for item in self{
                if nil == dic.index(of: item){
                    dic.append(item)
                }
            }
            return dic.count
        }
    }
}

その他

何も書くことないです。
ソースのどっかにこれコピペしたら使えるはずです。

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1