35 lines
827 B
Go
35 lines
827 B
Go
package lists
|
|
|
|
import "fmt"
|
|
|
|
func main () {
|
|
prices := []float64{10.99, 8.99}
|
|
fmt.Println(prices[0:1])
|
|
prices[1] = 9.99
|
|
|
|
prices = append(prices, 5.99, 12.99, 29.99, 100.10)
|
|
prices = prices[1:]
|
|
fmt.Println(prices)
|
|
|
|
discountedPrices := []float64{101.99, 80.99, 20.99}
|
|
prices = append(prices, discountedPrices...)
|
|
fmt.Println(prices)
|
|
}
|
|
|
|
// func main() {
|
|
// var productNames [4]string = [4]string{"A book"}
|
|
// prices := [4]float64{10.99, 9.99, 45.99, 20.0}
|
|
// fmt.Println(prices)
|
|
// fmt.Println(productNames)
|
|
|
|
// productNames[2] = "A carpet"
|
|
|
|
// fmt.Println(prices[2])
|
|
|
|
// featuredPrices := prices[1:]
|
|
// featuredPrices[0] = 199.99
|
|
// highlightedPrices := featuredPrices[:1]
|
|
// fmt.Println(highlightedPrices)
|
|
// fmt.Println(prices)
|
|
// fmt.Println(len(highlightedPrices), cap(highlightedPrices))
|
|
// } |