#HELP with returning value of function

35 messages · Page 1 of 1 (latest)

south egret
open nacelle
south egret
#

if you have an array of strings, you can use strings.Join to make them into one string

#

and then printing that is easier

open nacelle
#

but how would i be able

south egret
#

or you can use %v in your fmt.Printf format string to just "stringify" anything you pass in

open nacelle
#

to display the returned value

south egret
#

fmt.Printf prints to the stdout

open nacelle
#

should i type initial_decide in the place of xxxx?

#

What i dont understand is, how do i print out the value's of the array, what should i put instead of the xxxx

thick patrol
#

Println takes a variadic response, so you could pass that in as a second parameter

#

fmt.Println("foo", myvar)

open nacelle
#
func main() {

    naam_splitsen()
    initial_decide(naam_splitsen())
    fmt.Printf("Your initials are: ", initial_decide() )
}
#

this doesnt work

thick patrol
#

Because initial_decide takes an argument

open nacelle
#

yeah but it also returns something

thick patrol
#

You could capture the return value and put it in the print

#

myvar := myfunc()

#

These should all be in the tour, which I highly recommend if you haven't done it 🙂

open nacelle
thick patrol
#

Because you need to give it an arg

#

It wants a string slice, you're passing nothing

open nacelle
#

but im giving it naam_splitsen[]

#

oh i get it..

#

but i dont thin

#

k

#

it will work

#

i fixed it

#
func main() {

    test := initial_decide(naam_splitsen())
    fmt.Println("Your initials are: ", test)
}
#

this worked for me

#

@thick patrol thanks alot!

#

I will do the go tour but i need to finish this first

#

@thick patrol i also got 1 more question

thick patrol
#

🥳