GOLANG_INTERVIEW Telegram 233
👣 Какие есть особенности синтаксиса получения и записи значений в map?

Ответ:
Получить значение из map, которую мы предварительно не аллоцировали нельзя, приложение упадет в панику.

Если ключ не найден в map в ответ мы получим дефолтное значение для типа значений map. То есть, для строки - это будет пустая строка, для int - 0 и так далее. Для того, чтобы точно понять, что в map действительно есть значение, хранящееся по переданному ключу, необходимо использовать специальный синтаксис. А именно, возвращать не только само значение, но и булевую переменную, которая показывает удалось-ли получить значение по ключу.


@golang_interview
Please open Telegram to view this post
VIEW IN TELEGRAM
👍196👎5🔥2👌1



tgoop.com/golang_interview/233
Create:
Last Update:

👣 Какие есть особенности синтаксиса получения и записи значений в map?

Ответ:
Получить значение из map, которую мы предварительно не аллоцировали нельзя, приложение упадет в панику.

Если ключ не найден в map в ответ мы получим дефолтное значение для типа значений map. То есть, для строки - это будет пустая строка, для int - 0 и так далее. Для того, чтобы точно понять, что в map действительно есть значение, хранящееся по переданному ключу, необходимо использовать специальный синтаксис. А именно, возвращать не только само значение, но и булевую переменную, которая показывает удалось-ли получить значение по ключу.


@golang_interview

BY Golang вопросы собеседований


Share with your friend now:
tgoop.com/golang_interview/233

View MORE
Open in Telegram


Telegram News

Date: |

The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers. ZDNET RECOMMENDS During a meeting with the president of the Supreme Electoral Court (TSE) on June 6, Telegram's Vice President Ilya Perekopsky announced the initiatives. According to the executive, Brazil is the first country in the world where Telegram is introducing the features, which could be expanded to other countries facing threats to democracy through the dissemination of false content. Each account can create up to 10 public channels In handing down the sentence yesterday, deputy judge Peter Hui Shiu-keung of the district court said that even if Ng did not post the messages, he cannot shirk responsibility as the owner and administrator of such a big group for allowing these messages that incite illegal behaviors to exist.
from us


Telegram Golang вопросы собеседований
FROM American