FAQ
Hi all,
Is it possible to have an anonymous interface implementation (something
similar to anonymous structs)? In the code below I'd like to have a foo
implementation without declaring a struct.

-------------------------------------------------------------------
package main

type T interface {
Foo()
}

func Bar(t T) {
t.Foo()
}

func main() {
Bar(nil) //need quick foo implementation here without declaring a type and
declaring a method on it
}
--------------------------------------------------------------------

Thanks!

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 30, '13 at 1:28a
activeJun 30, '13 at 1:33a
posts2
users2
websitegolang.org

2 users in discussion

Dave Cheney: 1 post Shkarupin: 1 post

People

Translate

site design / logo © 2022 Grokbase