View Single Post
  #6  
Old 03-25-2004, 07:07 AM
ndnet
Hill Giant
 
Join Date: Oct 2003
Posts: 105
Default

In general, braces {} are used to block code together, such as:

if(condition){code block to execute}

Parentheses are used for a couple of reasons: 1.) Group together mathematical expressions to control evaluation order (things are evaluated in the parentheses together before things outside, and 2.) Enclosing the arguments of a function.

Quick examples of each.

1.) Controlling the order in which expressions are evaluated.

1 + 5 / 7 = 12/7 = ~1.714
but
(1+5) / 7 = 6/7 = ~0.857

2.) Passing arguments to a function

quest::say("Hello $name");

quest::say() is a function that takes an argument, your string there, which is passed by enclosing it in parentheses.

Code:
if ($text=~ /Hail/i && $ulevel >= 10){quest::say("Hello $name")
should probably be:

Code:
if ($text=~ /Hail/i && $ulevel >= 10){quest::say("Hello $name");}
Should end lines with semicolons. Also good practice to keep watch of what braces {} and parentheses () you open to make sure you close them later.
Reply With Quote