Skip to content
Discussion options

You must be logged in to vote

Your final println has bad syntax for printing the addr value. Instead of

	println('adress:{$addr')

it should be

	println('adress:${addr}')

There's really no reason to take the address of addr and assign it to address, either.

Here's how I changed your example:

module main

import os
import strconv

struct Address {
pub:
        street string
        city   string
        zip    int
}

fn make_address() Address {
        print('Enter a street:')
        street := os.get_line()
        print('Enter a city:')
        city := os.get_line()
        print('Enter a zip code:')
        zipstr := os.get_line()
        zip := strconv.atoi(zipstr) or {
                println('Failed to make a number'

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by LukyGuyLucky
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants