Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [trait]

A scala trait is roughly the equivalent of an interface in Java. It can be extended as if it were a class, and can contain concrete and abstract methods as well as variables.

1
vote
1answer
40 views

Proper naming for objects which have a position and bounds on a plane

I have an interface which is for an object which has bounds in a 2D plane. ...
1
vote
0answers
61 views

Choosing names for “logic” and “implementation” traits in Stackable trait pattern

I have a trait that is to be mixed-in with existing types of Actor classes in Akka and offer a certain functionality. To offer better maintenance, I am using the stackable trait pattern. The ...
0
votes
1answer
157 views

Scala implicit conversion to add methods to Int

I started learning Scala, and like most functional languages, things get messy pretty quickly for a beginner. Here I have built a wrapper class for Ints so that I ...
0
votes
1answer
83 views

Using Traits for set methods

I have an abstract class Consumer: ...
2
votes
0answers
3k views

Laravel 5 Dependency Injecting a Repository into a controller, and depedency injecting an entity into repository

Overview:: I have a Restful API that pushes all /api/{version}/{Repository} into my ResourceV{1}Controller depending on the <...
11
votes
1answer
1k views

Macro to build type declaration

These are some macros to help build a traits class (for the parser/printer classes I am building). Traits.h ...
50
votes
3answers
35k views

Trait accessing variables of classes using it

I just tried PHP Traits for the first time, to keep my code DRY : ...
2
votes
2answers
3k views

PHP Trait Singleton

An implementation of the singleton pattern in PHP using a trait (added in 5.4). Is there anything missing, any ways to create a second copy of the class? ...