When I format this, I get “expected expression”. What are they expecting?
https://play.golang.org/p/6MlEdlkgFwb I saw a mistake, and fixed it.
Now I got “missing ‘,’ in argument list”. I don’t know where they want a comma.
Still working on it. https://play.golang.org/p/uMFXAcFuX0Z
When I ran it, I got “prog.go:9:71: syntax error: unexpected int, expecting comma or )
prog.go:11:2: syntax error: unexpected for at end of statement
prog.go:18:6: syntax error: unexpected yearlyincrease, expecting (
prog.go:23:1: syntax error: non-declaration statement outside function body”
Each of these is a mystery to me.
Good question, right? lol
Well, the ultimate goal is to “pass a func into a func as an argument”.
So I thought I would print each year from 2019-2024, and for each year show an increase of 1,000. So I attempted to make a function that would calculate the increase, and then call that function when I listed each year. Could I use a callback to accomplish this even?
A type determines a set of values together with operations and methods specific to those values. A type may be denoted by a type name , if it has one, or specified using a type literal , which composes a type from existing types.
Well … writing every program starting with some template. And if you write code incrementally and not copy-paste you can’t get many compile error at one time. Right?
Compile time error is basic level , for fixing it should be enough only main pages from documentation/ examples from the package / … quick google search at the end.
Bear with me.
Your code https://play.golang.org/p/PHODb5FUY-B
My code https://play.golang.org/p/ZegcfjAzHT5
Ignore my comments .
Why am I getting this error message when I format? “prog.go:11:6: expected ‘(’, found test (and 1 more errors)”.
By the way, what does 11:6 mean. I get the 11 part; I’m confused by the 6
You can not create a namend function inside another function. You have to create an anonymous function and assign it to a variable. That is why you get that error.
file.go:11:6 means, in the file file.go at line 11, the 6th column. Be aware though, that indenting with a TAB counts as a single column per tab.
A type name is neither a named or anonymous function. Its just a type, types though can be used to describe named or unnamed functions if they are of func-“kind”.
Here, from GreyShatter. He uses “printInt” int apparently the same place that I use “incomeforthe nextfouryears” in https://play.golang.org/p/inVJYZc93XD
Yet I get an error message: “prog.go:11:6: expected ‘(’, found test (and 1 more errors)”
What did I miss?
Let me start again. The objective is a hands-on exercise with a callback…" * pass a func into a func as an argument".
So my idea was to make a function that listed several years, 2019-2023, and to pass in a function that would calculate the yearly increase (my idea was start with 40,000 and increase by 1000 each year). Does that even make sense to try?