Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*I've commented where the error is. I think the compiler output was weird for this kind of error.*/
- /***** Code ******/
- use std::io::println;
- fn is_three(num: int) -> bool {
- num % 3 == 0
- }
- fn is_five(num: int) -> bool {
- num % 5 == 0
- }
- fn is_fftn(num: int) -> bool {
- num % 15 == 0
- }
- #[test]
- fn test_is_three_with_not_three() {
- if is_three(1) {
- fail!("One is not three");
- }
- }
- #[test]
- fn test_is_three() {
- if is_three(1) {
- fail!("One is not three");
- }
- }
- fn main() {
- for num in range(1,101) {
- let answer =
- if is_fftn(num) {
- "FizzBuzz"
- }
- else if is_three(num) {
- "Fizz"
- }
- else if { //missing conditional
- "Buzz"
- }
- else {
- ""
- };
- println(answer);
- }
- }
- /***** Compiler output *****/
- ~/Dropbox/rust$ rustc fizzbuzz.rs
- fizzbuzz.rs:41:7: 41:11 error: expected `{` but found `else`
- fizzbuzz.rs:41 else {
- ^~~~
- ***
- I would have expected something like "error: missing/expected conditional at line 38, but found '{'"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement