Standard library / sync/atomic

atomic.Uintptr.And()

Atomically apply bitwise AND and return the previous value (Go 1.23+). Expected stdout: '12\n8\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Uintptr) And(mask uintptr) (old uintptr)

Parameters & Attributes

NameTypeDescription
maskuintptrBit mask used by the atomic operation.

Return Value

(old uintptr)

Previous value before AND.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync/atomic")
func main() { var x atomic.Uintptr; x.Store(12); fmt.Println(x.And(10)); fmt.Println(x.Load()) }
Go Reference