1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/masx200-the-way-to-go_ZH_CN

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
employee_salary.go 522 Байты
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Bo-Yi Wu Отправлено 11.02.2017 07:28 ca79293
// methods1.go
package main
import "fmt"
/* basic data structure upon with we'll define methods */
type employee struct {
salary float32
}
/* a method which will add a specified percent to an
employees salary */
func (this *employee) giveRaise(pct float32) {
this.salary += this.salary * pct
}
func main() {
/* create an employee instance */
var e = new(employee)
e.salary = 100000
/* call our method */
e.giveRaise(0.04)
fmt.Printf("Employee now makes %f", e.salary)
}
// Employee now makes 104000.000000

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/masx200-the-way-to-go_ZH_CN.git
git@api.gitlife.ru:oschina-mirror/masx200-the-way-to-go_ZH_CN.git
oschina-mirror
masx200-the-way-to-go_ZH_CN
masx200-the-way-to-go_ZH_CN
master