General Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

MULTIPLY EACH ITEM IN A LIST BY 2

A

(1..10).map { |n| n * 2 } How does this work?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Sum a list of numbers

A

(1..1000).inject(:+)

Explain your code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

words = ["scala", "akka", "play framework", "sbt", "typesafe"]

tweet = "This is an example tweet talking about scala and sbt."

Which words in words is in tweet?

A

words.any? { |word| tweet.include?(word) }

Explain your code: ie, how does this work?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Read the lines of a file into an array of strings

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly