Skip to content

Commit b9d995b

Browse files
authored
change spaces to tabs in generics.md (quii#556)
1 parent c8472e8 commit b9d995b

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

generics.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ func TestAssertFunctions(t *testing.T) {
2727
}
2828

2929
func AssertEqual(t *testing.T, got, want int) {
30-
t.Helper()
30+
t.Helper()
3131
if got != want {
3232
t.Errorf("got %d, want %d", got, want)
3333
}
3434
}
3535

3636
func AssertNotEqual(t *testing.T, got, want int) {
37-
t.Helper()
37+
t.Helper()
3838
if got == want {
39-
t.Errorf("didn't want %d", got)
39+
t.Errorf("didn't want %d", got)
4040
}
4141
}
4242
```
@@ -48,8 +48,8 @@ Being able to assert on the equality of integers is great but what if we want to
4848

4949
```go
5050
t.Run("asserting on strings", func(t *testing.T) {
51-
AssertEqual(t, "hello", "hello")
52-
AssertNotEqual(t, "hello", "Grace")
51+
AssertEqual(t, "hello", "hello")
52+
AssertNotEqual(t, "hello", "Grace")
5353
})
5454
```
5555

@@ -138,14 +138,14 @@ func TestAssertFunctions(t *testing.T) {
138138
}
139139

140140
func AssertEqual[T comparable](t *testing.T, got, want T) {
141-
t.Helper()
141+
t.Helper()
142142
if got != want {
143143
t.Errorf("got %v, want %v", got, want)
144144
}
145145
}
146146

147147
func AssertNotEqual[T comparable](t *testing.T, got, want T) {
148-
t.Helper()
148+
t.Helper()
149149
if got == want {
150150
t.Errorf("didn't want %v", got)
151151
}
@@ -379,13 +379,13 @@ Add the following test,
379379
380380
```go
381381
t.Run("interface stack dx is horrid", func(t *testing.T) {
382-
myStackOfInts := new(StackOfInts)
382+
myStackOfInts := new(StackOfInts)
383383

384-
myStackOfInts.Push(1)
385-
myStackOfInts.Push(2)
386-
firstNum, _ := myStackOfInts.Pop()
387-
secondNum, _ := myStackOfInts.Pop()
388-
AssertEqual(firstNum+secondNum, 3)
384+
myStackOfInts.Push(1)
385+
myStackOfInts.Push(2)
386+
firstNum, _ := myStackOfInts.Pop()
387+
secondNum, _ := myStackOfInts.Pop()
388+
AssertEqual(firstNum+secondNum, 3)
389389
})
390390
```
391391

@@ -401,21 +401,21 @@ To get around this, the caller has to do a [type assertion](https://golang.org/r
401401

402402
```go
403403
t.Run("interface stack dx is horrid", func(t *testing.T) {
404-
myStackOfInts := new(StackOfInts)
404+
myStackOfInts := new(StackOfInts)
405405

406-
myStackOfInts.Push(1)
407-
myStackOfInts.Push(2)
408-
firstNum, _ := myStackOfInts.Pop()
409-
secondNum, _ := myStackOfInts.Pop()
406+
myStackOfInts.Push(1)
407+
myStackOfInts.Push(2)
408+
firstNum, _ := myStackOfInts.Pop()
409+
secondNum, _ := myStackOfInts.Pop()
410410

411-
// get our ints from out interface{}
412-
reallyFirstNum, ok := firstNum.(int)
413-
AssertTrue(t, ok) // need to check we definitely got an int out of the interface{}
411+
// get our ints from out interface{}
412+
reallyFirstNum, ok := firstNum.(int)
413+
AssertTrue(t, ok) // need to check we definitely got an int out of the interface{}
414414

415-
reallySecondNum, ok := secondNum.(int)
416-
AssertTrue(t, ok) // and again!
415+
reallySecondNum, ok := secondNum.(int)
416+
AssertTrue(t, ok) // and again!
417417

418-
AssertEqual(t, reallyFirstNum+reallySecondNum, 3)
418+
AssertEqual(t, reallyFirstNum+reallySecondNum, 3)
419419
})
420420
```
421421

@@ -429,27 +429,27 @@ Here's our new `Stack` implementation, featuring a generic data type.
429429

430430
```go
431431
type Stack[T any] struct {
432-
values []T
432+
values []T
433433
}
434434

435435
func (s *Stack[T]) Push(value T) {
436-
s.values = append(s.values, value)
436+
s.values = append(s.values, value)
437437
}
438438

439439
func (s *Stack[T]) IsEmpty() bool {
440-
return len(s.values)==0
440+
return len(s.values)==0
441441
}
442442

443443
func (s *Stack[T]) Pop() (T, bool) {
444-
if s.IsEmpty() {
445-
var zero T
446-
return zero, false
447-
}
448-
449-
index := len(s.values) -1
450-
el := s.values[index]
451-
s.values = s.values[:index]
452-
return el, true
444+
if s.IsEmpty() {
445+
var zero T
446+
return zero, false
447+
}
448+
449+
index := len(s.values) -1
450+
el := s.values[index]
451+
s.values = s.values[:index]
452+
return el, true
453453
}
454454
```
455455

@@ -489,7 +489,7 @@ You'll notice the syntax for defining generic data structures is consistent with
489489

490490
```go
491491
type Stack[T any] struct {
492-
values []T
492+
values []T
493493
}
494494
```
495495

0 commit comments

Comments
 (0)