Skip to content

Instantly share code, notes, and snippets.

@ventureproz
Created December 4, 2018 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ventureproz/d8dfb6adcccdc473ac6cdbf03761b039 to your computer and use it in GitHub Desktop.
Save ventureproz/d8dfb6adcccdc473ac6cdbf03761b039 to your computer and use it in GitHub Desktop.
Ruby Lesson #1
puts "what is your first name"
first_name = gets.chomp
puts "what is your first name"
last_name = gets.chomp
puts "Your full name is #{first_name} #{last_name}"
full_name = first_name + last_name
puts "Your full name reversed is #{first_name.reverse!} #{last_name.reverse!}"
puts "your name has #{full_name.length} characters in it"
@ventureproz
Copy link
Author

I didn't think of adding the - 1 to the characters length method and came up with the following code below to make that change to show adding the single character in string concatenation first_name + " " + last_name

puts "what is your first name"
first_name = gets.chomp
puts "what is your first name"
last_name = gets.chomp
puts "Your full name is #{first_name} #{last_name}"
full_name = first_name + " " + last_name
puts "Your full name reversed is #{first_name.reverse!} #{last_name.reverse!}"
puts "your name has #{full_name.length - 1} characters in it"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment