首頁 > 後端開發 > Golang > 主體

學習GO:02

Patricia Arquette
發布: 2024-10-06 14:07:29
原創
219 人瀏覽過

Learning GO: 02

Hey! I am Currently learning Go Lang, and I am taking some basic Notes on my Notion and though I'd also just publish them here. They are not well thought out or well written but it's just me taking notes from time to time for my reference.

I am taking the Udemy Course by Maximilian Schwarzmüller,

Notes

Variable Declarations

variables can be declared via “var” keyword

and also with special assignment operator “:=” so with that we can remove the “var” keyword

this assignment operator is useful when we dont have to change the type of variable that is assigned by GO

because with “:=” we can not declare the type of variable

expectedReturn float64 := 5.5

above is invalid

expectedReturn := 5.5

above is valid

we can declare multiple variables at the same time with same type

var investmentAmount, years float64 = 1000, 10
登入後複製

if we dont declare the type of variable on that line then we can also declare multiple variables with different types

var investmentAmount, years  = 1000, "10"
登入後複製

以上是學習GO:02的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:dev.to
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!