Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Go
/
Constraints and type sets
What must a type satisfy for the constraint `interface { ~string; IsValid() bool }`?
from Constraints and type sets
Go 1.27
intermediate
1 min
What must a type satisfy for the constraint `interface { ~string; IsValid() bool }`?
It must have underlying type string and an IsValid() bool method.
Either a string underlying type or the method is sufficient.
Only the predeclared string type can satisfy it.
The value is converted to string before the method check.
Check
Ask AI about this kata
Report an error
next kata
What does this program print?
Predict the output
A new version is available
Reload