Skip to content

Why is array and dictionary + generic when other operators are not? #16

@sodiboo

Description

@sodiboo

public static func + <T>(lhs: [T], rhs: [T]) -> [T] {
var result = lhs
for i in rhs.GetSequence() {
result.append(i)
}
return result
}
public static func + <T>(lhs: Array<T>, rhs: ISequence<T>) -> Array<T> {
var result = lhs
for i in 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.

public static func + <T>(lhs: [Key:Value], rhs: [Key:Value]) -> [Key:Value] {
var result = lhs
for k in rhs.keys {
result[k] = rhs[k]
}
return result
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions