GO_INTERVIEW_LIB Telegram 639
Что выведет следующий код и почему?
package main

import "fmt"

func main() {
i := 0
defer fmt.Println("Result:", i)
i++
}

Выведется 0, потому что defer захватывает значение переменных на момент объявления, а не на момент выполнения отложенной функции.
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥27👍4



tgoop.com/go_interview_lib/639
Create:
Last Update:

Что выведет следующий код и почему?

package main

import "fmt"

func main() {
i := 0
defer fmt.Println("Result:", i)
i++
}

Выведется 0, потому что defer захватывает значение переменных на момент объявления, а не на момент выполнения отложенной функции.

BY Библиотека Go для собеса | вопросы с собеседований


Share with your friend now:
tgoop.com/go_interview_lib/639

View MORE
Open in Telegram


Telegram News

Date: |

As five out of seven counts were serious, Hui sentenced Ng to six years and six months in jail. Ng, who had pleaded not guilty to all charges, had been detained for more than 20 months. His channel was said to have contained around 120 messages and photos that incited others to vandalise pro-government shops and commit criminal damage targeting police stations. Hui said the time period and nature of some offences “overlapped” and thus their prison terms could be served concurrently. The judge ordered Ng to be jailed for a total of six years and six months. 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 Библиотека Go для собеса | вопросы с собеседований
FROM American