Skip to content
Quiz · Interfaces · lesson 4 of 10

Quiz — String() and receivers

Question 1 of 2

What does the program print?

GO
package main

import "fmt"

type Celsius float64

func (c Celsius) String() string { return fmt.Sprint(float64(c)) + "°C" }

func main() {
    t := Celsius(21)
    fmt.Println(t, float64(t))
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way