Dynamic Object Creation

Hello.

How can I create an object with a reference to a Class? For example if I want to write the following function:

makeRoom(roomClass) {
local newRoom = new roomClass();
return newRoom;
}

I get:
“error: cannot apply operator ‘new’ to this expression”

I have tried new (roomClass)(); and so on, nothing seems to work.

Ah roomClass.createInstance()