Skip to content

Add default value to To_____ methods #218

@bagualing

Description

@bagualing

I suggest adding a default value to all 'To___' methods.

Before:

// ToBool casts an interface to a bool type.
func ToBool(i interface{}) bool {
	v, _ := ToBoolE(i)
	return v
}

After:

// ToBool casts an interface to a bool type.
func ToBool(i interface{}, default ...bool) bool {
	v, err := ToBoolE(i)
        if err != nil && len(default) > 0 {
            return default[0]
        }
	return v
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions