type car struct {
brand string
model string
}
type truck struct {
car
bedSize int
}
lanesTruck := truck{
bedSize: 10,
car: car{
brand: "Toyota",
model: "Camry",
},
}
fmt.Println(lanesTruck.brand) // Toyota
fmt.Println(lanesTruck.model) // Camry
package main
func createMatrix(rows, cols int) [][]int {
matrix := make([][]int, 0)
for _ = range rows {
matrix = append(matrix, make([]int, cols))
}
for i := range matrix {
for j := range matrix[i] {
matrix[i][j] = i * j
}
}
return matrix
}
package main
func createMatrix(rows, cols int) [][]int {
matrix := make([][]int, rows)
for i := 0; i < rows; i++ {
matrix[i] = make([]int, cols)
for j := 0; j < cols; j++ {
matrix[i][j] = i * j
}
}
return matrix
}