DEV Community

Discussion on: Learn Go by writing tests: Structs, methods, interfaces & table driven tests

Collapse
 
quii profile image
Chris James

Glad it's helpful!

I hope this will help: play.golang.org/p/gTXh3vhOj-z

Basically when you pass a value into a function that takes a float, if the type hasn't been explicitly resolved, it will coerce it into a float (if it can, it wouldnt do it on a string).

So when you say "why can you pass integers", well you're not really. It's just 2 is being turned into a float.

Does that make sense?

Collapse
 
hrishin profile image
Hrishikesh Shinde

Thanks Chris. Yes that makes sense.