If there were such a thing I would imagine the syntax to be something along the lines of
while(Integer item : group<Integer>; item > 5)
{
//do something
}
Just wondering if there was something like this or a way to imitate this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, the closest would be:
Of course if Java ever gets concise closures, it would be reasonable to write something like .NET’s
Enumerable.TakeWhilemethod to wrap the iterable (groupin this case) and make it finish early if the condition stops holding.That’s doable even now of course, but the code to do it would be ugly. For reference, the C# would look like this:
Maybe Java will get nice closures some time…