1 00:00:00,600 --> 00:00:03,900 Hello and welcome to this lecture in this lecture. 2 00:00:03,990 --> 00:00:15,050 Be showing you how to interact with Ruby using the interactive Ruby Shell also referred to as I R B. 3 00:00:15,330 --> 00:00:26,880 What is interactive Ruby interactive Ruby is a program that outputs or shows the results of any ruby 4 00:00:26,880 --> 00:00:31,670 statements that you feed to it or give to it. 5 00:00:31,770 --> 00:00:41,970 So any statement you write within the interactive Ruby console it all out pulled the result in the way 6 00:00:42,000 --> 00:00:43,110 it works. 7 00:00:43,190 --> 00:00:50,120 Like he cark later that outboards whatever you put into it. 8 00:00:50,550 --> 00:00:58,200 There are different ways you can access the interactive Ruby base on the type of operating system or 9 00:00:58,200 --> 00:00:59,610 computer you have. 10 00:01:00,030 --> 00:01:09,090 If you are on his Mac OS X you basically typing Hi hard be on the terminal and that will give you access 11 00:01:09,090 --> 00:01:09,850 to it. 12 00:01:09,990 --> 00:01:14,970 If you are running Linux you open the shell and type in hi. 13 00:01:14,990 --> 00:01:16,330 Ah B. 14 00:01:16,560 --> 00:01:25,740 If you are running Windows there is an interactive Ruby icon which is located inside the ruby folder 15 00:01:26,280 --> 00:01:28,830 in your program's files. 16 00:01:29,290 --> 00:01:39,900 I am on a Windows based computer so I'm going to go to my files and there is my ruby folder inside the 17 00:01:39,900 --> 00:01:40,900 room before there. 18 00:01:40,920 --> 00:01:45,360 There is a folder court interactive Ruby this icon here. 19 00:01:45,460 --> 00:01:52,950 I just click on that and that will launch my interactive Ruby interactive Ruby is cat like a quick way 20 00:01:53,370 --> 00:01:56,430 to get acquainted with certain commands. 21 00:01:56,430 --> 00:02:02,510 Ruby So if you got single commas you one test out why your bidding application came quickly. 22 00:02:02,520 --> 00:02:07,940 Time the command to an interactive Ruby and it to just return an output. 23 00:02:08,020 --> 00:02:12,400 Say a good playground to experiment to begin. 24 00:02:12,420 --> 00:02:15,910 I'm going to type in the command where you see the cursor flashing. 25 00:02:15,910 --> 00:02:18,540 That means he's waiting for some command. 26 00:02:18,730 --> 00:02:21,500 So I'm just going to type in a text. 27 00:02:21,550 --> 00:02:23,820 I am going to type P in hell a word. 28 00:02:24,150 --> 00:02:27,250 If you're using a if you type in a string. 29 00:02:27,660 --> 00:02:31,400 You have to enclose that in quite a string. 30 00:02:31,410 --> 00:02:39,780 Basically is the text says he held a wall and press and time the keyboard and is giving me hell a while 31 00:02:39,810 --> 00:02:40,360 back. 32 00:02:40,590 --> 00:02:48,870 So a busy akeley obeys your command so whatever you tell it to do it will help put the result for you. 33 00:02:49,170 --> 00:02:54,910 So when you use when you say Hell a world there it gives you hell awhile back. 34 00:02:55,230 --> 00:02:58,650 Let's write another one this time we are going to use. 35 00:02:58,700 --> 00:03:11,480 He put a command so when a typing puts followed by a space and then quotes type in hell of world. 36 00:03:12,790 --> 00:03:14,970 Hello world. 37 00:03:17,430 --> 00:03:19,320 Press and tap on your keyboard. 38 00:03:19,490 --> 00:03:24,150 If you notice a difference when you use the Puts there are no quotes. 39 00:03:24,150 --> 00:03:29,540 If you listen here I just typed in hellowallet and interactive show business you just repeated what 40 00:03:29,540 --> 00:03:30,700 I typed in. 41 00:03:30,740 --> 00:03:32,150 You can see his written. 42 00:03:32,280 --> 00:03:39,870 But when I use the puts Command put put basically a command that is used to display output on the screen 43 00:03:40,500 --> 00:03:43,940 he has not returned the output with the quotes. 44 00:03:43,950 --> 00:03:46,390 Notice a quote I'm not here. 45 00:03:47,300 --> 00:03:53,120 So if you want to output anything on the screen using Ruby you use the puts we use. 46 00:03:53,120 --> 00:03:56,100 Put it also once he returns it outputs. 47 00:03:56,200 --> 00:04:00,600 He can also give you a carriage return. 48 00:04:00,600 --> 00:04:04,110 Also notice this here this is nil. 49 00:04:04,290 --> 00:04:08,170 I didn't get that when I just typed in the hello world. 50 00:04:08,330 --> 00:04:17,260 Well when they use puts I get this also has return the value is also giving me this name here. 51 00:04:18,870 --> 00:04:23,330 Neil is basically the result of the expression. 52 00:04:23,670 --> 00:04:24,300 Okay. 53 00:04:24,450 --> 00:04:28,990 So when you're using puts it will always return. 54 00:04:29,010 --> 00:04:31,580 Value of Neal Neal means nothing. 55 00:04:31,590 --> 00:04:32,540 It's not a value. 56 00:04:32,640 --> 00:04:34,190 It is nothing. 57 00:04:34,260 --> 00:04:41,670 Let's try a few Appalachian sad to see seven plots seven. 58 00:04:41,740 --> 00:04:45,360 If you notice it's just return value. 59 00:04:45,580 --> 00:04:47,170 There's no Neil involved. 60 00:04:47,180 --> 00:04:52,800 If I do put this time to say seven. 61 00:04:54,280 --> 00:04:57,510 Plus 7. 62 00:04:57,750 --> 00:04:59,410 Notice the nil. 63 00:04:59,410 --> 00:05:05,710 So when you use the inputs it will always return that nil value which means absolutely nothing. 64 00:05:05,710 --> 00:05:09,030 That's how it will express itself. 65 00:05:09,040 --> 00:05:15,730 You can do all kinds of calculation on here mojos addition so you can do multiplication as well if you 66 00:05:15,730 --> 00:05:19,170 wanted to do multiplication of 5. 67 00:05:19,510 --> 00:05:26,180 In Ruby do the multiplication symbol is an asterix to do Asterix times 5. 68 00:05:26,320 --> 00:05:29,220 That will give you a return 25. 69 00:05:29,230 --> 00:05:29,890 All right. 70 00:05:30,160 --> 00:05:33,870 Let's experiment with a couple more commands. 71 00:05:34,000 --> 00:05:41,110 So I'm going to typing in another command here so I'd do a double quotes. 72 00:05:41,430 --> 00:05:46,070 Hard typing 0 0 p. 73 00:05:46,950 --> 00:05:47,560 Ha. 74 00:05:47,600 --> 00:05:49,160 Hey hey. 75 00:05:49,750 --> 00:05:57,430 For opera I am going to use the dot limberness say reverse. 76 00:05:57,640 --> 00:06:00,020 So what I'm seeing here I am. 77 00:06:00,040 --> 00:06:07,850 Everything in Ruby is an object so I'm telling you I'm telling the object to reverse itself. 78 00:06:08,070 --> 00:06:16,780 Okay I'm using the dot notation to tell it to revert it is the DOT that does the reverse and so I press 79 00:06:16,870 --> 00:06:20,610 Enter hard proud turns to harpole. 80 00:06:20,860 --> 00:06:23,660 Another command you can use See for example. 81 00:06:23,710 --> 00:06:27,170 Have quite helo in low I case. 82 00:06:27,480 --> 00:06:30,220 Want to convert that to our per case. 83 00:06:30,310 --> 00:06:34,270 I just type in use the dot notation and do you. 84 00:06:34,270 --> 00:06:44,350 P case press and to conveyers that to uppercase so interactive shell is a good way to learn about single 85 00:06:44,350 --> 00:06:47,710 commands in Ruby so you can test your commands. 86 00:06:47,710 --> 00:06:54,750 Play around with different things before you start writing a full statement in your text editor persuasive 87 00:06:54,810 --> 00:06:58,370 him very quick and use for play playground. 88 00:06:58,720 --> 00:07:00,910 Also notice the difference between the puts. 89 00:07:00,910 --> 00:07:07,120 When you use the ports it will always return a return value with that is nil. 90 00:07:07,120 --> 00:07:13,480 I have tests on the output so that's the difference between use in the I and not using the port so feel 91 00:07:13,480 --> 00:07:16,660 free to play around to a loft in New Addition. 92 00:07:16,690 --> 00:07:23,110 Everything single line commands are quite useful so feel free to play around with any commands that 93 00:07:23,110 --> 00:07:26,740 you come across that you can use in Ruby. 94 00:07:26,740 --> 00:07:28,280 So that's it for this lecture. 95 00:07:28,300 --> 00:07:29,470 Thanks for watching. 96 00:07:29,470 --> 00:07:30,360 Bye for now.