- Go Systems Programming
- Mihalis Tsoukalos
- 109字
- 2021-07-02 18:07:58
Naming the return values of a Go function
Unlike C, Go allows you to name the return values of a Go function. Additionally, when such a function has a return statement without any arguments, the function automatically returns the current value of each named return value. Note that such functions return their values in the order they were declared in the definition of the function.
Naming return values is a very handy Go feature that can save you from various types of bugs, so use it.
My personal advice is this: name the return values of your functions unless there is a very good reason not to do so.
推薦閱讀
- HTML5+CSS3+JavaScript從入門到精通:上冊(微課精編版·第2版)
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- C++ Builder 6.0下OpenGL編程技術
- Scratch真好玩:教小孩學編程
- Silverlight魔幻銀燈
- Banana Pi Cookbook
- 零基礎學MQL:基于EA的自動化交易編程
- Mastering ServiceNow(Second Edition)
- 零基礎輕松學SQL Server 2016
- Android開發案例教程與項目實戰(在線實驗+在線自測)
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(入門與提高篇)
- Visual C++開發入行真功夫
- Webpack實戰:入門、進階與調優
- Mastering Backbone.js
- Django 3.0入門與實踐