//
//  Array+Extension.swift
//  SpeakEasyLearnEnglish
//
//  Created by edy on 2025/7/3.
//

import UIKit

extension Array {
    subscript(safe index: Int) -> Element? {
        return indices.contains(index) ? self[index] : nil
    }
    
    func isEqual<T:Codable>(form data:[T]?) -> Bool {
        if type(of: self) != type(of: data) || self.count != data?.count {
            return false
        }
        for (i,v) in self.enumerated() {
            let st = data?[safe: i]
            if st != nil{
                continue
            }else{
                return false
            }
        }
        return true
    }
}
