Improbable Icon

What does the nothing.schema do in Hello World?

v10-1-0

#1

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?

Thanks!


#2

Hey!

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.


#3

Gotcha, that makes sense! Thanks for the explanation.


#4

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


#5

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