Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object WhileLoop {
- @tailrec
- def whileLoop(b: => Boolean, command: => Unit): Unit = {
- if (b) {
- (command);
- whileLoop(b, command)
- } else ()
- }
- def main(args: Array[String]): Unit = {
- val mas = Array(1, 2, 3)
- var i = 0
- whileLoop(i < mas.length, { println(i); i += 1 })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement