Gophercises > Blackjack AI > Doubling: cannot use MoveHit (value of type func(g *Game) error) as Move value in return statement

I have just completed a Doubling video of Blackjack AI.

My implementation of Play on humanAI is the same as the one in video (as far as I see).

func (ai humanAI) Play(hand []deck.Card, dealer deck.Card) Move {
	for {
		fmt.Println("Player:", hand)
		fmt.Println("Dealer:", dealer)
		fmt.Println("What will you do? (h)it, (s)tand, (d)ouble")
		var input string
		fmt.Scanf("%s\n", &input)
		switch input {
		case "h":
			return MoveHit   // <- note this
		case "s":
			return MoveStand  // <- this
		case "d":
			return MoveDouble  // <- and this
			fmt.Println("Invalid option:", input)

In Game.Play in game.go I’m getting move(g) (no value) used as value when I’m assigning err := move(g).

move(g) (no value) used as value

A little research on the above error says that I need to return something from ai.Play. But I am already returning Move there.

But at these places:

case "h":
    return MoveHit
case "s":
    return MoveStand
case "d":
    return MoveDouble

I’m getting:

cannot use MoveHit (value of type func(g *Game) error) as Move value in return statement

Please point out what I am doing wrong?

Here is the link to the complete ai.go and game.go:

Move ist defined to be a function that takes a Game and returns nothing, though the functions you return, do return an error. You either need to change your type definition or the functions implementation.

Hi @NobbZ, at the Doubling exercise, a return error was introduced. I am trying to match them as far as possible without copy-pasting.

I don’t know the gophercises, I am just pointing at the discrepancy in your code. Types don’t match up.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.