File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
type MyString string
8+
9+
func (myStr MyString) reverse() string {
10+
s := string(myStr)
11+
runes := []rune(s)
12+
13+
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
14+
runes[i], runes[j] = runes[j], runes[i]
15+
}
16+
return string(runes)
17+
}
18+
19+
func main() {
20+
myStr := MyString("OLLEH")
21+
fmt.Println(myStr.reverse())
22+
}
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424

2525
11. [Playing with Pointers in Golang](https://www.callicoder.com/golang-pointers/)
2626

27-
12. [Golang Structs Tutorial with Examples](https://www.callicoder.com/golang-structs/)
27+
12. [Golang Structs Tutorial with Examples](https://www.callicoder.com/golang-structs/)
28+
29+
13. [Golang Methods Tutorial with Examples](https://www.callicoder.com/golang-methods/)

0 commit comments

Comments
 (0)