PLDB
Languages Features Creators Calendar CSV Resources Blog About Donate Add Language
GitHub icon

Traits

< >
Example from 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 Jule:
trait Person { fn get_full_name(self): str fn get_age(self): byte }

Languages with Traits include PHP, Jule

Read more about Traits on the web: 1.

HTML of this page generated by Features.ts

hasTimestamps.html 路 hasTraits.html 路 hasTriples.html

View source

PLDB - Build the next great programming language Search v2023 Day 157 Docs Acknowledgements Traffic Today Traffic Trends Mirrors GitHub feedback@pldb.com