Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
haXe 2 Beginner's Guide

You're reading from  haXe 2 Beginner's Guide

Product type Book
Published in Jul 2011
Publisher
ISBN-13 9781849512565
Pages 288 pages
Edition 1st Edition
Languages

Table of Contents (21) Chapters

haxe 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting to know haXe 2. Basic Syntax and Branching 3. Being Cross-platform with haXe 4. Understanding Types 5. The Dynamic Type and Properties 6. Using and Writing Interfaces, Typedefs, and Enums 7. Communication Between haXe Programs 8. Accessing Databases 9. Templating 10. Interfacing with the Target Platform 11. A Dynamic Website Using JavaScript 12. Creating a Game with haXe and Flash Pop Quiz Answers Index

Type parameters


We have already discussed the typing system in haXe, but now, we are going to see the Type parameters. You may have already seen them in some languages, maybe under the name of Generics.

We will now see:

  • The usage of Type parameters

  • Using Type parameters with already created types

  • Creating a type that makes use of them

  • Creating an example

Let's continue discovering the typing system!

Usage of Type parameters

So far, you have only created functions that took some parameters with a defined type and returned a value with a defined type. You have always decided what these types were when creating your functions.

With Type parameters, it is possible to let the person use a class and decide what types will be used by some of its functions.

You may wonder why this is useful, and indeed, we have already used Type parameters in this book; remember how we said we were going to create an "Array of String"? Well, we have been using Type parameters at this moment.

In fact, Type parameters are like...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}