oops, an infitie loop in the As implementation, now the right one: https://go2goplay.golang.org/p/5NnZBnmIC96
среда, 17 июня 2020 г., 21:55:52 UTC+3 пользователь Denis Cheremisov написал: > > There's an advantage though, for rather narrow cases though: reuse of > interfaces: > > https://go2goplay.golang.org/p/HJr3QIzgQuX > > среда, 17 июня 2020 г., 19:58:08 UTC+3 пользователь Denis Cheremisov > написал: >> >> IMO a groups of constraints are horrible with interfaces >> >> type CommonResponse(type E) interface { >> GetError() E >> } >> >> type CommonError interface { >> GetCode() int32 >> } >> >> func IsOK(type R CommonResponse(E), E CommonError)(r R) bool { >> switch r.GetError().GetCode() { >> case 0, 200, 201: >> return true >> default: >> return false >> } >> } >> >> vs >> >> constract CommmonResponse(R, E) { >> R GetError() E >> E GetCode() int32 >> } >> >> func IsOK(type R, E CommonResponse)(r R) bool { >> switch r.GetError().GetCode() { >> case 0, 200, 201: >> return true >> default: >> return false >> } >> } >> >> That trickery with commas to express dependcy of types is hard >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/965c8563-8535-41e8-9f31-cc75dbe2b5c5o%40googlegroups.com.