Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
duck typing
<?php
// duck typing
final class Foo {
public function bar ($object) {
$object->quack();
}
}
// Because we know nothing about $object, it's only by calling quack that we can
// tell whether object supports quack()
// Same but with a language construct that statically declares the need for $object
// to support a quack method. It could now be verified at compile time.
final class Foo {
public function bar ($object :: quack()) {
$object->quack();
}
}
@Harrisonbro

This comment has been minimized.

Copy link

Harrisonbro commented Dec 1, 2016

@mathiasverraes Do other languages have this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.