I’m running this line:
<%= @date[i].created_at.strftime('%d').to_i.class %>
and the output is a fixnum rather than an int. Why is this?
From the controller:
@date = Lesson.find(:all, :order => 'created_at ASC')
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no such thing
intin Ruby.Fixnumis the class of small numbers like1or2that fit into a machine word, and it’s a subclass ofInteger. Check the following:So your value is a
Fixnum, anInteger, aNumericand anObjectat the same time 😉 This effect is called polymorphism and it might surprise you in this context because in some other programming languages numbers are treated in a special way (they have some kind of “native” type). In Ruby, numbers are just objects.