Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "errors"
- "fmt"
- )
- type Indirizzo struct {
- Citta string
- CAP string
- }
- type Persona struct {
- Nome string
- Cognome string
- Eta int
- Indirizzo
- //codice string
- }
- func (p *Persona) Invecchia() {
- p.Eta++
- //((*p).Eta)++
- }
- func main() {
- p1 := Persona{}
- var p2 = Persona{
- Nome: "Mario",
- Cognome: "Rossi",
- Eta: 30,
- }
- p2.Invecchia() //Invecchia(p2)
- fmt.Println(p1, p2)
- p2.Citta = "Milano";
- // map1 := make(map[string]int)
- // map1["Tevere"] = 406
- // map2 := map[string]float32{
- // "standard": 69.99,
- // "deluxe": 89,
- // "super deluxe": 129,
- // }
- // map2["stra super deluxe"] = 200
- // //ha la deluxe?
- // costo, esiste := map2["deluxe"]
- // if !esiste {
- // fmt.Println("Edizione non disponibile")
- // } else {
- // fmt.Println("Costo: ", costo)
- // }
- // delete(map2, "deluxe")
- // costo, esiste = map2["deluxe"]
- // if !esiste {
- // fmt.Println("Edizione non disponibile")
- // } else {
- // fmt.Println("Costo: ", costo)
- // }
- // //iteriamo sulla mappa
- // for key, value := range map2 {
- // fmt.Println(key, " Costo: ", value)
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement