From: Robert Gustavsson Date: 2001-01-06T03:59:09+09:00 Subject: [ruby-talk:8704] Braces and begin/end Hi! I opened parse.y and made a serious try to understand why but my knowledge of the parser generator language in parse.y is nil so I will once again annoy you fellas with a newbie question: The construction below does not work: ------------------------ a = 10 { print a, "\n" a -= 1 } while a > 0 ------------------------ Ruby says: ------------------------ Ruby1:4: parse error print a, "\n" ^ Ruby1:4: parse error Ruby1:6: parse error } while a > 0 ^(SyntaxError) from Ruby1 ------------------------ But if I replace { and } with begin and end it works: ------------------------ a = 10 begin print a, "\n" a -= 1 end while a > 0 ------------------------ Silly me thought that {} and begin/end was synonyms. Apparantly they aren't. Why not? Any other pitfalls about {} and begin/end one should be aware of? I must say that ruby-talk is a very positive experience so far. Very prompt and competent replies and very kind and helpful people. Hopefully I will gain some knowledge about Ruby to be able to contribute. Robert