I am already in lesson 2 Chapter 13 of cryptozombies tutorial. In feedAndMultiply function why they use keccak to compare Kitty rather the exact character.
if (keccak256(_species) == keccak256("kitty"))
why not
if (_species == "kitty") ?
The == operator is only supported for booleans, integers, fixed point numbers (once support for fixed point numbers is launched), addresses, and static byte arrays. Solidity does not support == for dynamic arrays (which string is). To work around this, they are simply taking the hash value of the two strings and then comparing the result.
The Types page in the Solidity docs outlines all of the supported operations for each type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With