4 ms·
Here's a variation of the example which I like a bit better: type CopyFile string func (src CopyFile) To(dest string) error { // copy file here
by agwa 7y ago
Here's a variation of the example which I like a bit better:
type CopyFile string
func (src CopyFile) To(dest string) error {
// copy file here
}
func main() {
CopyFile("presentation.md").To("/tmp/backup")
}
- shhsshs 7y agoNice, very clever!
- jonahx 7y agoThe problem is, even though it reads smoothly, the names are no longer accurate. The smoothness comes from reading "CopyFile" as a verb (semantically), but "CopyFile" is actually a noun (syntactically). Source("presentation.md").CopyTo("/tmp/backup") while scoring slightly fewer slickness points, wins overall imo because it remains accurate.