File tree Expand file tree Collapse file tree
1_Introduction/1_Hello_World Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ print 'Hello World'
Original file line number Diff line number Diff line change 1+ require 'rspec'
2+
3+ describe 'Your code' do
4+ it 'prints out "Hello World"' do
5+ expect { [ [ 'solution::code' ] ] } . to output ( 'Hello World' ) . to_stdout
6+ end
7+ end
Original file line number Diff line number Diff line change 1+ # Say Hello World in Ruby
2+
3+ In Ruby you can print to the standard output by using the * print* method.
4+ If you want to print a new line you can use the * puts* (or the shorter * p* )
5+ method.
6+
7+ * print* and * puts* take one or multiple comma-separated objects as parameter
8+ and turns them into a String before printing to the the standard output
9+ * $stdout* .
10+
11+ ` print 'a' ` just prints out * a* .
12+ ` print 'a', 'b', 'c' ` prints out * abc* .
13+
14+ The two * ''* declare a Ruby String object. You can also use * ""* to create a
15+ String. We will discuss the difference of * ''* and * ""* later on.
16+
17+ ## For now, let's do the Hello World example in Ruby:
18+
19+ -----
20+
21+ Print out * Hello* * World* to the standard output!
22+
23+ -----
You can’t perform that action at this time.
0 commit comments