Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Traits

< >
Example from 1 languages: PHP
// The template trait TSingleton { private static $_instance = null; private function __construct(){} // Must have private default constructor and be aware not to open it in the class public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } class FrontController { use TSingleton; } // Can also be used in already extended classes class WebSite extends SomeClass { use TSingleton; }
Example from 1 languages: Jule
trait Person { fn get_full_name(self): str fn get_age(self): byte }
*

Languages with Traits include PHP, Jule

*

View all concepts with or missing a hasTraits measurement

*

Read more about Traits on the web: 1.

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements