31
31
# `new` method and a `<<` method. `Set` is one such type:
32
32
#
33
33
# ```
34
- # set = Set{1, 2, 3} # => [ 1, 2, 3]
34
+ # set = Set{1, 2, 3} # => Set{ 1, 2, 3}
35
35
# set.class # => Set(Int32)
36
36
# ```
37
37
#
@@ -313,7 +313,7 @@ class Array(T)
313
313
# ary[0] = 5
314
314
# p ary # => [5,2,3]
315
315
#
316
- # ary[3] = 5 # => IndexError
316
+ # ary[3] = 5 # raises IndexError
317
317
# ```
318
318
@[AlwaysInline ]
319
319
def []= (index : Int , value : T )
@@ -449,7 +449,7 @@ class Array(T)
449
449
# a = ["a", "b", "c", "d", "e"]
450
450
# a[1..3] # => ["b", "c", "d"]
451
451
# a[4..7] # => ["e"]
452
- # a[6..10] # => Index Error
452
+ # a[6..10] # raise IndexError
453
453
# a[5..10] # => []
454
454
# a[-2...-1] # => ["d"]
455
455
# ```
@@ -469,7 +469,7 @@ class Array(T)
469
469
# ```
470
470
# a = ["a", "b", "c", "d", "e"]
471
471
# a[-3, 3] # => ["c", "d", "e"]
472
- # a[6, 1] # => Index Error
472
+ # a[6, 1] # raise IndexError
473
473
# a[1, 2] # => ["b", "c"]
474
474
# a[5, 1] # => []
475
475
# ```
@@ -618,7 +618,7 @@ class Array(T)
618
618
# a = ["ant", "bat", "cat", "dog"]
619
619
# a.delete_at(2) # => "cat"
620
620
# a # => ["ant", "bat", "dog"]
621
- # a.delete_at(99) # => IndexError
621
+ # a.delete_at(99) # raises IndexError
622
622
# ```
623
623
def delete_at (index : Int )
624
624
index = check_index_out_of_bounds index
@@ -638,7 +638,7 @@ class Array(T)
638
638
# a = ["ant", "bat", "cat", "dog"]
639
639
# a.delete_at(1..2) # => ["bat", "cat"]
640
640
# a # => ["ant", "dog"]
641
- # a.delete_at(99..100) # => IndexError
641
+ # a.delete_at(99..100) # raises IndexError
642
642
# ```
643
643
def delete_at (range : Range (Int , Int ))
644
644
from, size = range_to_index_and_count(range)
@@ -654,7 +654,7 @@ class Array(T)
654
654
# a = ["ant", "bat", "cat", "dog"]
655
655
# a.delete_at(1, 2) # => ["bat", "cat"]
656
656
# a # => ["ant", "dog"]
657
- # a.delete_at(99, 1) # => IndexError
657
+ # a.delete_at(99, 1) # raises IndexError
658
658
# ```
659
659
def delete_at (index : Int , count : Int )
660
660
val = self [index, count]
@@ -1014,7 +1014,7 @@ class Array(T)
1014
1014
# iter.next # => [2, 3, 1]
1015
1015
# iter.next # => [3, 1, 2]
1016
1016
# iter.next # => [3, 2, 1]
1017
- # iter.next # => Iterator::Stop
1017
+ # iter.next # => #< Iterator::Stop>
1018
1018
# ```
1019
1019
#
1020
1020
# By default, a new array is created and returned for each permutation.
@@ -1109,8 +1109,8 @@ class Array(T)
1109
1109
# ```
1110
1110
# s = [1, 2, 3] # => [1, 2, 3]
1111
1111
# t = [4, 5, 6, [7, 8]] # => [4, 5, 6, [7, 8]]
1112
- # u = [9, [10, 11].each] # => [9, Indexable# ItemIterator]
1113
- # a = [s, t, u, 12, 13] # => [[1, 2, 3], [4, 5, 6, [7, 8]], 9, 10 ]
1112
+ # u = [9, [10, 11].each] # => [9, #<Indexable:: ItemIterator> ]
1113
+ # a = [s, t, u, 12, 13] # => [[1, 2, 3], [4, 5, 6, [7, 8]], 9, #<Indexable::ItemIterator>, 12, 13 ]
1114
1114
# a.flatten # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
1115
1115
# ```
1116
1116
def flatten
@@ -1325,7 +1325,7 @@ class Array(T)
1325
1325
# ```
1326
1326
# a = ["a", "b"]
1327
1327
# a.push("c") # => ["a", "b", "c"]
1328
- # a.push(1) # => Errors, because the array only accepts String.
1328
+ # a.push(1) # Errors, because the array only accepts String.
1329
1329
#
1330
1330
# a = ["a", "b"] of (Int32 | String)
1331
1331
# a.push("c") # => ["a", "b", "c"]
@@ -1714,12 +1714,12 @@ class Array(T)
1714
1714
#
1715
1715
# ```
1716
1716
# a = ["a", "b"]
1717
- # a.unshift("c") # => ["c", a", "b"]
1718
- # a.unshift(1) # => Errors, because the array only accepts String.
1717
+ # a.unshift("c") # => ["c", " a", "b"]
1718
+ # a.unshift(1) # Errors, because the array only accepts String.
1719
1719
#
1720
1720
# a = ["a", "b"] of (Int32 | String)
1721
1721
# a.unshift("c") # => ["c", "a", "b"]
1722
- # a.unshift(1) # => [1, "a ", "b ", "c "]
1722
+ # a.unshift(1) # => [1, "c ", "a ", "b "]
1723
1723
# ```
1724
1724
def unshift (obj : T )
1725
1725
insert 0 , obj
0 commit comments