Swift4でjoinedが使えない

Swift4でjoinedが使えない

 

エラー内容

 

$ swift build
Compile Swift Module 'PerfectTemplate' (2 sources)
/opt/bitnami/apache2/htdocs/PerfectTemplate/Sources/main.swift:36:12: error: ambiguous reference to member 'joined()'
    print( uploads.joined(separator: ",") )
           ^~~~~~~
Swift.Sequence:25:17: note: found this candidate
    public func joined() -> FlattenSequence<Self>
                ^
Swift.Sequence:16:17: note: found this candidate
    public func joined<Separator>(separator: Separator) -> JoinedSequence<Self> where Separator : Sequence, Separator.Element == Self.Element.Element
                ^
Swift.Sequence:16:17: note: found this candidate
    public func joined(separator: String = default) -> String
                ^
Swift.Collection:25:17: note: found this candidate
    public func joined() -> FlattenCollection<Self>
                ^
Swift.BidirectionalCollection:25:17: note: found this candidate
    public func joined() -> FlattenBidirectionalCollection<Self>
                ^
Swift.BidirectionalCollection:16:17: note: found this candidate
    public func joined(separator: String = default) -> String
                ^
error: terminated(1): /usr/share/swift/usr/bin/swift-build-tool -f /opt/bitnami/apache2/htdocs/PerfectTemplate/.build/debug.yaml main

 

解決

 

let array = request.postParams
print( type(of:"\(array.map({ String(describing: $0) }).joined(separator: ""))") )
//String

 

藤沢瞭介(Ryosuke Hujisawa)
  • りょすけと申します。18歳からプログラミングをはじめ、今はフロントエンドでReactを書いたり、AIの勉強を頑張っています。off.tokyoでは、ハイテクやガジェット、それからプログラミングに関する情報まで、エンジニアに役立つ情報を日々発信しています!

未整理記事