Z
Z
ZeroSkill2021-07-17 22:55:34
JavaScript
ZeroSkill, 2021-07-17 22:55:34

How can this scribbling at the syntax level be reduced?

Here I have this code:

w.uint8(1);
w.uint16(this.id);
w.uint16(this.x);
w.uint16(this.y);
w.color(this.color)

how it is possible to write down what would be for example as in JAVA. Something like:
w.uint8(1),
 .uint16(this.id),
 .uint16(this.x),
 .uint16(this.y),
 .color(this.color);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RokeAlvo, 2021-07-18
@ZeroSkill

it all depends on what the methods return. If inside they return this (i.e. the object instance itself), then you can do this:
w.method1().method2().method3()

A
abberati, 2021-07-17
@abberati

This is chaining. Achieved using code widely described on the Internet, googled by name. We'll have to write a wrapper over w

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question