Created
June 2, 2017 17:31
-
-
Save paulredmond/17e0649bdd8c4d355cd980c9cf635ec1 to your computer and use it in GitHub Desktop.
Java equivalent example (I think) of the PHP Generics RFC Example
This file contains 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
public class Entry<KeyType, ValueType> | |
{ | |
protected KeyType key; | |
protected ValueType value; | |
public Entry(KeyType key, ValueType value) { | |
key = key; | |
value = value; | |
} | |
public KeyType getKey() { | |
return key; | |
} | |
public ValueType getValue() { | |
return value; | |
} | |
} |
This file contains 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
<?php | |
class Entry<KeyType, ValueType> | |
{ | |
protected $key; | |
protected $value; | |
public function __construct(KeyType $key, ValueType $value) | |
{ | |
$this->key = $key; | |
$this->value = $value; | |
} | |
public function getKey(): KeyType | |
{ | |
return $this->key; | |
} | |
public function getValue(): ValueType | |
{ | |
return $this->value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment