| publicstaticfunc+<T>(lhs:[T], rhs:[T])->[T]{ |
| varresult= lhs |
| foriin rhs.GetSequence(){ |
| result.append(i) |
| } |
| return result |
| } |
| |
| publicstaticfunc+<T>(lhs:Array<T>, rhs:ISequence<T>)->Array<T>{ |
| varresult= lhs |
| foriin rhs { |
| result.append(i) |
| } |
| return result |
| } |
These two definitions for + are generic, but the other operators are not. The other operators can still use the generic type parameter from the array type itself, why does the + use its own generic type parameter? Same thing for Dictionary.
| publicstaticfunc+<T>(lhs:[Key:Value], rhs:[Key:Value])->[Key:Value]{ |
| varresult= lhs |
| forkin rhs.keys { |
| result[k]=rhs[k] |
| } |
| return result |
| } |
SwiftBaseLibrary/Source/Array.swift
Lines 246 to 260 in 64cb429
These two definitions for + are generic, but the other operators are not. The other operators can still use the generic type parameter from the array type itself, why does the + use its own generic type parameter? Same thing for Dictionary.
SwiftBaseLibrary/Source/Dictionary.swift
Lines 156 to 162 in 64cb429