GOLANGPROFI Telegram 360
Что выведет код ?

package main

import "fmt"

func foo(a []int) {
a = append(a, 7)
a[1] = 7
}

func bar(a *[]int) {
*a = append(*a, 7)
}

func main() {
a := []int{1, 2, 3, 4, 5, 6}
fmt.Printf("a[1]=%d\n", a[1])

b := a[1:3]
b[0] = 10
fmt.Printf("1. a[1]=%d\n", a[1]) // что выведет?

b = append(b, a...)
b[0] = 100
fmt.Printf("2. a[1]=%d\n", a[1]) // что выведет?

foo(a)
fmt.Printf("3. a[1]=%d\n", a[1]) // что выведет?

bar(&a)
fmt.Printf("4. a=%v\n", a) // что выведет?
}


Ответ



tgoop.com/golangprofi/360
Create:
Last Update:

Что выведет код ?

package main

import "fmt"

func foo(a []int) {
a = append(a, 7)
a[1] = 7
}

func bar(a *[]int) {
*a = append(*a, 7)
}

func main() {
a := []int{1, 2, 3, 4, 5, 6}
fmt.Printf("a[1]=%d\n", a[1])

b := a[1:3]
b[0] = 10
fmt.Printf("1. a[1]=%d\n", a[1]) // что выведет?

b = append(b, a...)
b[0] = 100
fmt.Printf("2. a[1]=%d\n", a[1]) // что выведет?

foo(a)
fmt.Printf("3. a[1]=%d\n", a[1]) // что выведет?

bar(&a)
fmt.Printf("4. a=%v\n", a) // что выведет?
}


Ответ

BY Golang Юниор




Share with your friend now:
tgoop.com/golangprofi/360

View MORE
Open in Telegram


Telegram News

Date: |

Polls Read now How to create a business channel on Telegram? (Tutorial) To delete a channel with over 1,000 subscribers, you need to contact user support Hashtags are a fast way to find the correct information on social media. To put your content out there, be sure to add hashtags to each post. We have two intelligent tips to give you:
from us


Telegram Golang Юниор
FROM American