fix: refactor feet to meter exercises
This commit is contained in:
@ -20,7 +20,7 @@ package main
|
|||||||
func main() {
|
func main() {
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
// 1. Define Feet and Meters types below
|
// 1. Define Feet and Meters types below
|
||||||
// Their underlying type can be int64
|
// Their underlying type can be float64
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
@ -32,7 +32,7 @@ func main() {
|
|||||||
|
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
// 3. Get feet value from the command-line
|
// 3. Get feet value from the command-line
|
||||||
// 4. Convert it to an int64 first using ParseFloat
|
// 4. Convert it to an float64 first using ParseFloat
|
||||||
// 5. Then, convert it into a Feet type
|
// 5. Then, convert it into a Feet type
|
||||||
// ... TYPE YOUR CODE HERE
|
// ... TYPE YOUR CODE HERE
|
||||||
|
|
||||||
|
@ -13,11 +13,12 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WHY?
|
|
||||||
// Because, you can add methods to your types in the future
|
|
||||||
// And, they're type-safe and more readable now.
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// WHY ADDING YOUR OWN TYPES IS IMPORTANT?
|
||||||
|
//
|
||||||
|
// 1. Type-Safety
|
||||||
|
// 2. Increased Readability
|
||||||
|
// 3. Adding Methods to your Types
|
||||||
type (
|
type (
|
||||||
Feet float64
|
Feet float64
|
||||||
Meters float64
|
Meters float64
|
||||||
|
Reference in New Issue
Block a user