Search code examples
ruby-on-railsrailstutorial.org

4.1.2. Hartl rails tutorial. Why "def full_title(page_title = '')" and not just "def full_title(page_title)"


Helper goes like:

module ApplicationHelper

  # Returns the full title on a per-page basis.
  def full_title(page_title = '')
    base_title = "Ruby on Rails Tutorial Sample App"
    if page_title.empty?
      base_title
    else
      page_title + " | " + base_title
    end
  end
end

I don't understand why there is "page_title = ' ' " instead of just argument "page_title"

Thanks,


Solution

  • It is default value. When calling full_title if you not pass page_title it will take default '' - blank string