今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
The empty interface
- [Instructor] An empty interface is simply a methodless interface. It means any and everything implemented. And that can have a profound implication for our programs and when it comes to things like compiler type checking, for example. The empty interface denoted by the keyword interface with a set of empty braces means there's no type information for the compiler to check against, but that doesn't mean there's no underlying type information. Here's what I mean. We'll declare a whatAmI function and that function is going to accept a val and its type is going to be the empty interface, and we'll return a string. We'll return a formatted string using the thumb package's Sprintf function, specifying the percent V for the value, and percent T for the type of the value that we're sending in. In our main, we'll then invoke the whatAmI function first with an integer, then with a string, right? Now let's run our program…