Standard library / math/big
big.Rat.Set()
Copy a rational value into another receiver; do not shallow-copy the struct. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '2/3 4/1\n'.
Formal Syntax & Structure
go syntaxgo
func (z *Rat) Set(x *Rat) *RatParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | *Rat | Numeric operand supplied to this method. |
Return Value
*Rat
Returns the result described above; see the example for the observed behavior.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/big")
func main() { x := big.NewRat(2, 3) z := new(big.Rat).Set(x) x.SetInt64(4) fmt.Println(z, x)}