2019-04-24 17:17:07 +00:00
|
|
|
## lastrune
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Instructions
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
Write a function that returns the last `rune` of a `string`.
|
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Expected function
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
func LastRune(s string) rune {
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Usage
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-02-25 12:02:16 +00:00
|
|
|
Here is a possible program to test your function :
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/01-edu/z01"
|
2020-04-26 21:45:09 +00:00
|
|
|
|
2021-05-02 15:18:17 +00:00
|
|
|
"piscine"
|
2019-04-24 17:06:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
z01.PrintRune(piscine.LastRune("Hello!"))
|
|
|
|
z01.PrintRune(piscine.LastRune("Salut!"))
|
|
|
|
z01.PrintRune(piscine.LastRune("Ola!"))
|
|
|
|
z01.PrintRune('\n')
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
And its output :
|
|
|
|
|
|
|
|
```console
|
2021-04-28 09:47:34 +00:00
|
|
|
$ go run .
|
2019-04-24 17:06:54 +00:00
|
|
|
!!!
|
2021-04-28 09:47:34 +00:00
|
|
|
$
|
2019-04-24 17:06:54 +00:00
|
|
|
```
|
2021-06-07 17:05:53 +00:00
|
|
|
|
|
|
|
### Notions
|
|
|
|
|
|
|
|
- [rune-literals](https://golang.org/ref/spec#Rune_literals)
|