Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Scalaで反復可能な文字列を別の文字列で「結合」するにはどうすればよいですか?
val thestrings = Array("a","b","c") val joined = ??? println(joined)
このコードを出力したいa,b,c(「,」で要素を結合)。
a,b,c
mkStringはどうですか?
theStrings.mkString(",")
プレフィックスとサフィックスも指定できるバリアントが存在します。
foldLeftを使用した実装については、 hereを参照してください。これははるかに冗長ですが、おそらく教育のために調べる価値があります。