Parametric polymorphism: Difference between revisions

added objc
(added objc)
Line 573:
value: T
left, right: Tree[T]</lang>
 
=={{header|Objective-C}}==
{{trans|C++}}
{{works with|Xcode|7}}
<lang objc>@interface Tree<T> : NSObject {
T value;
Tree<T> *left;
Tree<T> *right;
}
 
- (void)replaceAll:(T)v;
@end
 
@implementation Tree
- (void)replaceAll:(id)v {
value = v;
[left replaceAll:v];
[right replaceAll:v];
}
@end</lang>
Note that the generic type variable is only used in the declaration, but not in the implementation.
 
=={{header|OCaml}}==
Anonymous user