Fix: Type error in lasagna_master_test.go by converting portions to float64

This pull request fixes a type error in lasagna_master_test.go. The test was failing because an integer variable tt.portions was being used where a float64 was expected. This change converts tt.portions to float64 to resolve the error.

Error message:
./lasagna_master_test.go:205:34: cannot use tt.portions (variable of type int) as float64 value in argument to ScaleRecipe

After this change, the tests should pass without any type errors.

image

Typically portions is a whole number – an integer and not a float. Changing the tests may make your code work, but it work cause over 35,000 existing solutions, which currently work, to stop working. Are you sure it’s the test that has a bug and not your code?

Consider reading Chesterton's Fence | Exercism's Docs

tt.portions is an int, and it’s passed as the second argument of ScaleRecipe. What this tells you is that the second argument of ScaleRecipe should also be an int.

Since this exercise teaches about functions, it’s part of the exercise figuring out what the parameter and return types for the functions. The file you get when you download the exercise tries to suggest that it’s actually the first thing you should do before even trying to implement any logic:

// Your first steps could be to read through the tasks, and create
// these functions with their correct parameter lists and return types.
// The function body only needs to contain `panic("")`.
// 
// This will make the tests compile, but they will fail.
// You can then implement the function logic one by one and see
// an increasing number of tests passing as you implement more 
// functionality.

So, a failure in compilation because you have the wrong types in the function signature is expected and it’s part of the exercise, it just means you got the wrong type in your code and should change it. The idea is to keep the test code as is.

1 Like