Skip to content

Commit 6e5a500

Browse files
feat(exercises): add solution for 17_pointers (zhravan#124)
Co-authored-by: shravan || श्रvan <mrshravankumarb@gmail.com>
1 parent 779c534 commit 6e5a500

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package pointers
2+
3+
func modifyValue(ptr *int) *int {
4+
if ptr == nil {
5+
return nil
6+
}
7+
*ptr = 100
8+
return ptr
9+
}

internal/exercises/templates/17_pointers/pointers.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package pointers
22

3-
// TODO:
4-
// - Modify the value pointed to by the incoming *int.
5-
// - Return the same pointer after updating the underlying value.
6-
// - Avoid allocating any new memory; operate in place.
7-
3+
// TODO: Modify the value pointed to by the incoming *int.
4+
// Return the same pointer after updating the underlying value.
5+
// Avoid allocating any new memory; operate in place.
86
func modifyValue(ptr *int) *int {
97
// TODO: implement mutation via pointer
108
return ptr

0 commit comments

Comments
 (0)