Improbable Icon


What does the nothing.schema do in Hello World?



There is a schema for “Nothing” with the following code:

[code]package improbable.core;

type Nothing {}[/code]

I don’t quite understand why it is in there and also imported into Heartbeat and PlayerLifeCycle? Can anyone elaborate?




Good question; the Nothing type is used almost like a reusable Void or Empty type to implicitly indicate that one is not interested in the payload of either the request or response from a command.

You would have been correct to define the Heartbeat command as:

component Heartbeat {
  id = 1003;
  uint32 timeout_beats = 1;
command HeartbeatResponse heartbeat(HeartbeatRequest);

With HeartbeatResponse and HeartbeatRequest being types with no fields, too, in order to be more explicit:

type HeartbeatRequest {}
type HeartbeatResponse {}

But having the Nothing type just makes it convenient to reuse whenever you are not interested in sending along data nor receiving data from a command.


Gotcha, that makes sense! Thanks for the explanation.


Since this type is somewhat special and most likely included in most projects - have you thought about making it built in?


@kukki sure have - it’ll be coming in one of the next SDK versions :slight_smile: