Skip to content

Commit 0fa57df

Browse files
authored
Update README.md
Add description for ptr.ValueOrDefault
1 parent 02435c2 commit 0fa57df

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ if ptr.Value(in.OptionalField) == "value" {
6464
}
6565
```
6666

67+
or get value by specifying the default value when in.OptionalField is nil:
68+
6769
```go
6870
v := ptr.ValueOrDefault(in.OptionalField, "defaultValue")
6971
```
@@ -86,4 +88,4 @@ newPointer := ptr.Copy(in.OptionalField)
8688

8789
```shell
8890
go get github.com/elgopher/ptr@latest
89-
```
91+
```

0 commit comments

Comments
 (0)