Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function() : this(null) {}

Can someone please explain the following syntactic sugar?

protected MyConstructor() : this(null)

Mainly I am interested in this part: ": this(null)"

I know how protected, constructors and "this" keyword work, but am confused and cannot find any detailed information of the last part all put-together in all my online searches.

Edit: I should add that it is in a public abstract class. So I guess the constructor is calling the implementers constructor.

Thanks

like image 221
Seth Eden Avatar asked Jan 15 '14 17:01

Seth Eden


People also ask

WHAT IS null value of function?

Null values are the placeholders in the database when we have the data missing, or the required data is not available. A null value is not a part of any particular data type, it is a flexible data type and can be put in the column of any data type be it string, int, blob or CLOB datatype.

IS null == null in JavaScript?

null is a special value in JavaScript that represents a missing object. The strict equality operator determines whether a variable is null: variable === null . typoef operator is useful to determine the type of a variable (number, string, boolean).

IS NULL function in JavaScript?

JavaScript null is a primitive type that contains a special value null . JavaScript uses the null value to represent the intentional absence of any object value. If you find a variable or a function that returns null , it means that the expected object couldn't be created.

What is null type in JavaScript?

Null. In JavaScript null is "nothing". It is supposed to be something that doesn't exist. Unfortunately, in JavaScript, the data type of null is an object.


1 Answers

It calls another class constructor that has a parameter:

protected MyConstructor() : this(null) { }  // This calls the other constructor

protected MyConstructor(object whatever)
{
    Frob(whatever);
}
like image 63
itsme86 Avatar answered Sep 24 '22 22:09

itsme86