"Go boolPtr()"의 두 판 사이의 차이

(새 문서: ==개요== ; <syntaxhighlight lang='go'> package main import "fmt" // boolPtr은 Boolean 값을 포인터로 변환하는 함수입니다. func boolPtr(b bool) *bool { return &...)
 
7번째 줄: 7번째 줄:
import "fmt"
import "fmt"


// boolPtr은 Boolean 값을 포인터로 변환하는 함수입니다.
func boolPtr(b bool) *bool {
func boolPtr(b bool) *bool {
     return &b
     return &b

2024년 11월 10일 (일) 19:51 판

개요

package main

import "fmt"

func boolPtr(b bool) *bool {
    return &b
}

func main() {
    truePtr := boolPtr(true)
    falsePtr := boolPtr(false)

    fmt.Println("truePtr:", *truePtr)
    fmt.Println("falsePtr:", *falsePtr)
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}