In java some standard library methods (Maybe they're not actually methods?) have the following format:
keyword(condition or statements) {
//write your code here
}
This includes the if-statement, for-loop, while-loop do-while-loop etc.
for(initialValue = n; conditionForLoopToContinue; incrementOrDecrement) {
//write your code
}
Also you can start anonymus threads like so:
new Thread() {
//write your code here
}.start();
What I want to know is Can we create our own methods (or whatever you they're actually called) that have this curly bracket format?
So , for example, I would write an 'until' method that goes like this:
int a = 0;
until(a == 10) {
a++;
}
where until(a == 10) would be equivalent to while(a != 10).
Of course, the example above wouldn't allow us to do anything new (we can just use a while-loop), but the purpose of this question is to find out whether we can write 'custom curly bracket methods'.
Also, if you guys are a aware of any language that has this feature or one similar to it, please let me know.
Thanks for any help in advance!