Last active
August 4, 2016 14:56
-
-
Save ladrift/96d83c82750d2f0d0feb2a3240d08d09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Mutex struct{} | |
func (m *Mutex) Lock() {} | |
func (m *Mutex) Unlock() {} | |
type PtrMutex *Mutex | |
func main() { | |
m := &Mutex{} | |
m.Lock() | |
var pm PtrMutex | |
//pm.Lock() // illegal: pm don't have method Lock. | |
pm1 := (*Mutex)(pm) | |
pm1.Lock() // But the underlying type has its methods. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment