Start learning free

LESSON 168 OF 679 · LOOPS & CONDITIONALS

Positive Number In Array: Buggy Code in Rust

Practice

Inside the code editor we've tried to write a function that takes a vector nums as argument and returns true if there exists at least one positive (greater than zero) number in the vector; returns false otherwise.

So when we called the function for vec![-1, 2, 3], we expected our code to print:

Array has positive numbers

but it seems like we made some mistakes: the compiler rejects our code with a mismatched types error (expected bool, found ()), and even once that is fixed, the code would print:

Array doesn't have positive numbers

Assignment:

Your task is to fix our function.

STEP 1 OF 1
    Ctrl + Enter to check