Install the Rails gem if you haven't done so before
putsconverts value to string.pdoes no conversion. Prints the true value.- Everything in Ruby is an object!
- The pound sign/hash is for single line comments.
- Multiline comments require
=beginand=end - Integers are whole numbers
- An expression is a bit of code that yeilds a value.
- Math can be performed on string objects.
The following is an explanation of Ruby blocks and yield by another Bloc mentor (Adam Louis) who was trying to explain it to one of his students.
On my very first day programming, if someone asked me for "the sum of the numbers from 1 to 10", I'd have written:
puts 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
Easy enough.
- This file declares a class,
Player, instantiates it, and assigns it to a globalplayervariable. - The
Playerclass contains four methods:constructor()playPause()skipTo()setVolume()
- The
constructor()method sets initial values for thecurrentlyPlaying,playState,volume, andsoundObjectproperties.currentlyPlayingis set to the first item inalbum.songs.- The initial
playStateis"stopped".
- The
volumeis set to the number80.
