Message-ID: <1126410896.1735.1427451759917.JavaMail.email@example.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1734_133078889.1427451759917" ------=_Part_1734_133078889.1427451759917 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.=20
*A .NET ru= ntime - either Microsoft's .NET Runtime on = Windows, or Mono on Linux.
*Your favorite text editor.<= br /> *Being comfortable with the command-line, for now.
*Free time.<= /p>=20
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.=20
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!
Now, type,=20 =20
You'll see "Hello, world!" printed on screen. Welcome to Boo.<= /p>=20
Print is an expression in Boo that is used to feed output to a device ca=
lled "Standard Output."
Ignoring the concept of "Stand= ard Output" completely, what it means (for now) is that the "prin= t" expression will just show text in the console, like you just saw wi= th 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,=20 =20
but everytime we wanted to say hello to someone new, we would be in quit= e a quandary!=20
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,= =20 =20
and save the file.=20
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.=20 =20
Neat, eh, but what happened?=20 =20
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 = typing the namespace, 'System,' before everything." Why would you do t= his? 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.=20 =20
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.=20
*Create a program that reads in the user's name and pri= nts outs something like, "Your name is $name. Hello, $name!" exce= pt that $name is replaced with the user's name.
*Create a program tha= t reads in the user's first name, and then the user's last name, and print = them together, like, "Your name is $firstname $lastname." 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.=20
*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.