new2cpp new2cpp - 1 year ago 45
Ruby Question

What's the purpose of question mark in the beginning of variable? has some example code

def create
?user = User.find_by(email: params[:session][:email].downcase)
if ?user && ?user.authenticate(params[:session][:password])
log_in ?user
params[:session][:remember_me] == '1' ? remember(?user) : forget(?user)
redirect_to ?user
else[:danger] = 'Invalid email/password combination'
render 'new'

However, I still cannot understand the purpose of
here. It is not a typo, right?

Answer Source

Just before this example there is an intro to it:

By filling in the missing elements in Listing 9.27 and Listing 9.28 (indicated with question marks ? and FILL_IN), complete this improved test of the “remember me” checkbox.

It always makes sense to read tutorials, not to scan them with a broken eye.