utils

package
v1.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsBool

func AsBool(v any) bool

func AsFloat

func AsFloat(v any) (float64, bool)

AsFloat converts a value to float64 if possible. Returns the float value and a boolean indicating success.

func AsFloatArg

func AsFloatArg(args []any, i int) (float64, bool)

func AsInt

func AsInt(v any) (int, bool)

func AsIntArg

func AsIntArg(args []any, i int) (int, bool)

func AsStringArg

func AsStringArg(args []any, i int) string

func CanBeInt added in v1.1.3

func CanBeInt(f float64) bool

CanBeInt checks if a float64 value can be represented as an integer without loss of precision Returns true if the float is a whole number (e.g., 3.0, -5.0, 0.0)

func ToString

func ToString(v any) string

ToString converts a value to its string representation. This handles all Polyloft types including primitive wrappers, class instances, etc. For better environment handling, use ToStringWithEnv when an environment is available.

func ToStringWithEnv added in v1.1.10

func ToStringWithEnv(v any, env *common.Env) string

ToStringWithEnv converts a value to its string representation with proper environment handling. When env is provided, it's used as the parent for method calls on class instances. This ensures builtin classes are accessible when toString methods are called.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL