Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for ExampleClone (0.17 sec)

  1. src/maps/example_test.go

    // Use of this source code is governed by a BSD-style
    // license that can be found in the LICENSE file.
    
    package maps_test
    
    import (
    	"fmt"
    	"maps"
    	"strings"
    )
    
    func ExampleClone() {
    	m1 := map[string]int{
    		"key": 1,
    	}
    	m2 := maps.Clone(m1)
    	m2["key"] = 100
    	fmt.Println(m1["key"])
    	fmt.Println(m2["key"])
    
    	m3 := map[string][]int{
    		"key": {1, 2, 3},
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Oct 11 20:21:56 UTC 2023
    - 2.2K bytes
    - Viewed (0)
  2. src/slices/example_test.go

    	slices.SortStableFunc(people, func(a, b Person) int {
    		return strings.Compare(a.Name, b.Name)
    	})
    	fmt.Println(people)
    	// Output:
    	// [{Alice 20} {Alice 55} {Bob 24} {Gopher 13}]
    }
    
    func ExampleClone() {
    	numbers := []int{0, 42, -10, 8}
    	clone := slices.Clone(numbers)
    	fmt.Println(clone)
    	clone[2] = 10
    	fmt.Println(numbers)
    	// Output:
    	// [0 42 -10 8]
    	// [0 42 -10 8]
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 10 17:28:50 UTC 2024
    - 8.1K bytes
    - Viewed (0)
  3. src/strings/example_test.go

    // Use of this source code is governed by a BSD-style
    // license that can be found in the LICENSE file.
    
    package strings_test
    
    import (
    	"fmt"
    	"strings"
    	"unicode"
    	"unsafe"
    )
    
    func ExampleClone() {
    	s := "abc"
    	clone := strings.Clone(s)
    	fmt.Println(s == clone)
    	fmt.Println(unsafe.StringData(s) == unsafe.StringData(clone))
    	// Output:
    	// true
    	// false
    }
    
    func ExampleBuilder() {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 09 22:05:38 UTC 2023
    - 10.7K bytes
    - Viewed (0)
Back to top