Also const the return?

Near the end we fix the function const correctness, but shouldn’t you also const the return value?

bool const UBullCowCartridge::IsIsogram(const FString& word) const {}

Seems like we should let the calling scope know it cannot mutate our return value, either!

This is being returned by value so callers would still be able to modify their variable they store this in (provided it’s non-const obviously).

Returning by const value is rarely what you ever want as it disables move semantics.

1 Like

Privacy & Terms