Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 39e6d73

Browse files
committed
Thomas' homework
1 parent e38ac00 commit 39e6d73

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

week1/homework/questions.txt

+12
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ p.86-90 Strings (Strings section in Chapter 6 Standard Types)
44

55
1. What is an object?
66

7+
An object is anything "we manipulate in Ruby." This would not, for example, include variables, because a variable is merely a reference to an object.
8+
79
2. What is a variable?
810

11+
A variable is a reference to an object.
12+
913
3. What is the difference between an object and a class?
1014

15+
A class is an object, but an object is not necessarily a class. Any class is an object of the class Class, and like any object it will inherit relevant class properties. However unlike a class a non-class object will not contain methods or reference a superclass.
16+
1117
4. What is a String?
1218

19+
Strings are sequences of characters. They are objects of class String.
20+
1321
5. What are three messages that I can send to a string object? Hint: think methods
1422

23+
chomp, split, count
24+
1525
6. What are two ways of defining a String literal? Bonus: What is the difference between the two?
26+
27+
You can define a string literal by wrapped text in either single quotes or double quotes. The difference between the two is that a double quoted string can support more escape sequences.

week1/homework/strings_and_rspec_spec.rb

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
before(:all) do
1313
@my_string = "Renée is a fun teacher. Ruby is a really cool programming language"
1414
end
15-
it "should be able to count the charaters"
16-
it "should be able to split on the . charater" do
17-
pending
18-
result = #do something with @my_string here
15+
it "should be able to count the characters" do
16+
@my_string.should have(66).characters
17+
end
18+
it "should be able to split on the . character" do
19+
result = @my_string.split('.')
1920
result.should have(2).items
2021
end
2122
it "should be able to give the encoding of the string" do
22-
pending 'helpful hint: should eq (Encoding.find("UTF-8"))'
23+
@my_string.encoding.should eq (Encoding.find("UTF-8"))
2324
end
2425
end
2526
end

0 commit comments

Comments
 (0)