Optional arguments for peripheral methods #837
Answered
by
SquidDev
Mathilde411
asked this question in
Q&A
-
Hello again ! I want to create a method for a peripheral that has a nullable parameter. @LuaFunction
public final void write(ByteBuffer bytes, @Nullable String label) throws LuaException {
byte[] data = Util.getByteBufferArray(bytes);
if (data.length > Config.MAX_MAG_CARD_DATA)
throw new LuaException("You can't put more than " + Config.MAX_MAG_CARD_DATA + " characters in a mag card.");
getTile().writeCard(data, label);
}
@LuaFunction
public final void write(ByteBuffer bytes) throws LuaException {
this.write(bytes, null);
} But I always get |
Beta Was this translation helpful? Give feedback.
Answered by
SquidDev
Jun 18, 2021
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Mathilde411
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Nullable
isn't available at runtime I don't believe, and so we can't check for it.Optional<String>
should work.