gpt4 book ai didi

scala - Scala中的Seq和Set有什么区别

转载 作者:行者123 更新时间:2023-12-04 06:23:37 27 4
gpt4 key购买 nike

var seq = Seq[String]()
seq = seq :+ "hello"

var set = Set[String]()
set += "hello"

Seq和Set有什么区别?

最佳答案

序号

http://www.scala-lang.org/api/current/scala/collection/Seq.html

Sequences always have a defined order of elements. Sequences provide a method apply for indexing.


Seqjava.util.List相似。



http://www.scala-lang.org/api/current/scala/collection/Set.html

A set is a collection that contains no duplicate elements.



这在数学意义上非常类似于“集合”: http://en.wikipedia.org/wiki/Set_(mathematics)
Setjava.util.Set相似。

关于scala - Scala中的Seq和Set有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19803158/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com