Skip to content

Commit 0016e34

Browse files
authored
Merge pull request scala#3106 from gkepka/mutable-collection-classes-fix
Fix `Stack` example
2 parents 0264d13 + 6458adb commit 0016e34

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

_overviews/collections-2.13/concrete-mutable-collection-classes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ You've now seen the most commonly used immutable collection classes that Scala p
1616

1717
## Array Buffers
1818

19-
An [ArrayBuffer](https://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/mutable/ArrayBuffer.html) buffer holds an array and a size. Most operations on an array buffer have the same speed as for an array, because the operations simply access and modify the underlying array. Additionally, array buffers can have data efficiently added to the end. Appending an item to an array buffer takes amortized constant time. Thus, array buffers are useful for efficiently building up a large collection whenever the new items are always added to the end.
19+
An [ArrayBuffer](https://www.scala-lang.org/api/{{ site.scala-version }}/scala/collection/mutable/ArrayBuffer.html) holds an array and a size. Most operations on an array buffer have the same speed as for an array, because the operations simply access and modify the underlying array. Additionally, array buffers can have data efficiently added to the end. Appending an item to an array buffer takes amortized constant time. Thus, array buffers are useful for efficiently building up a large collection whenever the new items are always added to the end.
2020

2121
{% tabs ArrayBuffer_1 %}
2222
{% tab 'Scala 2 and 3' for=ArrayBuffer_1 %}
@@ -148,11 +148,11 @@ res1: scala.collection.mutable.Stack[Int] = Stack(1)
148148
scala> stack.push(2)
149149
res0: stack.type = Stack(1, 2)
150150
scala> stack
151-
res3: scala.collection.mutable.Stack[Int] = Stack(1, 2)
151+
res3: scala.collection.mutable.Stack[Int] = Stack(2, 1)
152152
scala> stack.top
153153
res8: Int = 2
154154
scala> stack
155-
res9: scala.collection.mutable.Stack[Int] = Stack(1, 2)
155+
res9: scala.collection.mutable.Stack[Int] = Stack(2, 1)
156156
scala> stack.pop
157157
res10: Int = 2
158158
scala> stack
@@ -170,11 +170,11 @@ res1: scala.collection.mutable.Stack[Int] = Stack(1)
170170
scala> stack.push(2)
171171
res0: stack.type = Stack(1, 2)
172172
scala> stack
173-
res3: scala.collection.mutable.Stack[Int] = Stack(1, 2)
173+
res3: scala.collection.mutable.Stack[Int] = Stack(2, 1)
174174
scala> stack.top
175175
res8: Int = 2
176176
scala> stack
177-
res9: scala.collection.mutable.Stack[Int] = Stack(1, 2)
177+
res9: scala.collection.mutable.Stack[Int] = Stack(2, 1)
178178
scala> stack.pop
179179
res10: Int = 2
180180
scala> stack

0 commit comments

Comments
 (0)