06-01-2022
Ruby Workshop
p vs prints vs puts
-
p sends the following characters directly to the terminal
-
print sends the string to the terminal without
-
puts prints the string to the terminal
-
p is more explicit, Nice thinking Katerina!!!!! =D that's the sort of learning i'm here for
-
HOWEVER, never send p to a user!!!!
control flow
-
if ( this condition is true )
- execute this section of code
-
if the condition is true
##RUBY FLOW CONTROL
number = gets.chomp.to_i
Captain S, Sailor of the FizzBuzz Seas!
-= or -
remember that -=, += will reassign the value x - 1 will not reassign x
Ruby, Chapter 1
The programme is all that is the case (no, really!)
-
IRB
-
exit or quit to leave
-
IRB will not remember the programme, exiting will destroy the programme and assigned variables (assumedly using Ruby's garbage collector - it must run at exit?)
-
instead of using a REPL, you can store this software in a file
-
by using the Ruby keyword require, we can import the file into the programme where the REPL will immediately execute it
-
being in a REPL is like becoming the language
-
I AM RUBYYYY (ngl prefer t but w/e)
-
the world itself is an object - usually called main
-
remember, the main word for this is a 'prompt'
#Puts, Print, P, pp
- Puts (put string) includes the newline character \n at the end of the input
- Print does not include the newline character
- puts and print treat arrays differently. puts will also try .to_s on all array objects, hence it will include nil objects in the output
puts [1,2]
1
2
print [1,2]
[1,2]
puts [1, nil, nil, 4]
1
4
pp will pretty print! Ruby pre 2.4 must require 'pp' to access this method
RVM Problems
- RVM is having a fit because I installed homebrew(linuxbrew) after installing RVM - as such it isnt first in the path
in brief
fixed git issue
git config associates to email address directly to github account - beware!
gcm requires the 'store' helper setting
rvm sometimes require the command '/bin/bash --login' to be run before changing ruby versions
helped Hoom'n :) it felt a good thing to do - it helped another person
tried to learn a little sign. must try harder. maybe convince some others also?
received a MacBook, which I need to set up
tech evangelised another musician - need to curate him a learning list, including the touch typing thing
sent an email to makers
#First Thing Tomorrow