Message-ID: <1340605848.42487.1371726730780.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_42486_1414017650.1371726730780" ------=_Part_42486_1414017650.1371726730780 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This tutorial assumes you have basic computing knowledge and are comfort= able with the command line interface of your operating system. If you're fa= miliar with programming in general, you might just want to browse the code = snippets and ignore the rest of the article in general.
*A .NET runtime - either Microsoft's .NET R= untime on Windows, or Mono on Linux.
*Your favorite text editor.
*Being comfortable with the command-line, for now.
Before we even get started, its time to show you the obligatory "He= llo, world!" application. Every language tutorial has them, and Boo is= no exception! Everybody's gotta start somewhere.
Crack open Your Favorite Text Editor.
On the very first line, type,
Save the file as hello.boo, and make a note of the directory its been sa=
Go to the command prompt and find the directory you installed Boo into, and= go to the bin subdirectory. /boo/bin, if you will!
You'll see "Hello, world!" printed on screen. Welcome to Boo.<= /p>
Print is an expression in Boo that is used to feed output to a device ca=
lled "Standard Output."
Ignoring the concept of "Standard Output" completely, what it mea= ns (for now) is that the "print" expression will just show text i= n the console, like you just saw with the hello world program.
What if we want to get really specific - what if we want to print out so= meone else's name instead of just saying hello to the entire freaking plane= t, eh? We could, of course,
but everytime we wanted to say hello to someone new, we would be in quit= e a quandary!
But, never fear, for your hero is here, and he will now show you how to = read input from the user - don't worry, its really easy and you don't have = to worry about it. Crack open hello.boo and replace its contents with,
and save the file.
We'll break it down line-by-line in a second, but for now, run "boo= i" just like you did before, and stare in awe: nothing's happening! Al= l there is is a blinking cursor! Type your name and press enter. I typed &q= uot;Bongo," because I'm a freak.
Neat, eh, but what happened?
System is a namespace - its like a box with lots of delicious snacktreat=
s in it, or, if you're on a diet, like a box full of slightly stale protein=
bars. The "Console" class is one of these delicious treats, just=
waiting to be plucked from the box. We could have accessed the "Conso=
le" class by using "System.Console," but we didn't - why?
Using the "import" keyword is a way of saying, "dump all the= contents of the System namespace into my file so I don't have to keep typi= ng the namespace, 'System,' before everything." Why would you do this?= Because you're lazy, that's why.
Here you are doing two things - you are calling a member of the "Co= nsole" class, called "ReadLine()", and storing a value it re= turns into "name." ReadLine() is a method that waits for the user= to type something and press enter, and returns a string o= f characters. This string goes into the "name" object. Thus, were= the user - an upstanding citizen such as yourself - to type "Bongo,&q= uot; then "name" would now have the contents "Bongo" af= ter the user pressed the enter key.
This is the easiest part of the program - its called "String Interpolation" The curly b= race symbols essentially mean, 'embed this object inside of this string,' s= o when you write "$name" you are really saying, "replace $na= me with the contents of name." Since we typed in "Bongo" ear= lier and stored that in the name variable, instead of seeing "Hello, $= name" printed on the screen we will instead see, "Hello, Bongo.&q= uot; Take special note: using $<object> actually calls a special memb= er that every object has, called, 'ToString()' - this member returns a stri= ng that represents a formatted description of the object. Not all classes i= mplement their own custom ToString() member, so you might see something str= ange like 'System.DateTime' instead of the actual date and time.
*Create a program that reads in the user's name and prints outs something l= ike, "Your name is $name. Hello, $name!" except that $name is rep= laced with the user's name.
*Create a program that reads in the user's first name, and then the user's = last name, and print them together, like, "Your name is $firstname $la= stname." You'll need at least two variables, and if you just read the = last sentence, you'll probably have an inkling of how to do it. Re-examine = the
program if you are feeling lost.
*Tip: There are many more classes available in the System namespace - go= to Microsoft .NET Class guide and chec= k out the namespaces available - there are tons of classes inside! Remember= to use "import" or else you'll be typing System.Console" al= l year long.------=_Part_42486_1414017650.1371726730780--