Comments (2)
In Java you can declare that T extends a certain class to ensure the generic type is of that class. E.g. if you have an animal class and a cat class that extends animal, you could make a generic that is Something and now you can use Cat or Animal but not things that aren't Animal extensions for the type of Something.
So... is there equivalent in Haxe for ensuring the T extends something?
from haxe.org-comments.
@Mimerr you can add constraints to type parameters to specify that they implement or are subclasses of other interfaces/types. For example, the following Java declaration:
public void drawAll(List<? extends Shape> shapes) { ... }
Is roughly equivalent to this Haxe declaration:
public function drawAll<T:Shape>(shapes:List<T>):Void { ... }
from haxe.org-comments.
Related Issues (20)
- [haxe.org/manual] Logging and Trace HOT 2
- [haxe.org/manual] Anonymous Structure HOT 1
- [haxe.org/manual] Enum Instance HOT 3
- [haxe.org/introduction] compiler-targets HOT 2
- [haxe.org/manual] Final HOT 5
- [haxe.org/manual] Target defines HOT 2
- [haxe.org/manual] Type System
- [haxe.org/manual] Static Extension (Language Features) HOT 2
- [haxe.org/manual] Authors and contributions HOT 1
- [haxe.org/manual] Interfaces HOT 1
- [haxe.org/manual] new HOT 2
- [haxe.org/manual] Implementation details (Standard Library - Json) HOT 1
- [haxe.org/manual] Dynamic (Class Fields - Access Modifier) HOT 10
- [code.haxe.org] Abstract types - Email address as abstract type HOT 1
- [code.haxe.org] Beginner - Pattern matching HOT 2
- [code.haxe.org] Abstract types - Pipe using Abstract Operator Overloading HOT 2
- [haxe.org/manual] Target Details HOT 1
- [haxe.org/manual] Null Safety HOT 2
- [haxe.org/manual] Blocks HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haxe.org-comments.