On Tuesday, September 25, Todd Chester wrote: > Not to ask too obvious a question, but why does words use a [] > instead of a () ? > ... > I am confused as to when to use [] and when to use () with a method.
If a method is called without arguments, the () can be omitted. "a man a plan a canal -- panama".words() "a man a plan a canal -- panama".words # <-- same thing [] acts on the return value -- it takes an element of a list "a man a plan a canal -- panama".words()[3] "a man a plan a canal -- panama".words[3] # <-- same thing Brian