Archive for February 24th, 2008
Learn from mistakes
SHOCK, HORROR, DISASTER,
Your MARK SHEET must have got exchanged. The examiner must have been out of his mind. The exam system should be abolished. You cant understand
HOW IT HAPPENED,
but it has HAPPENED, You have not done as well as
YOU EXPECTED…..
Or
as well as everyone
EXPECTED YOU TO DO.
NOW WHAT ???
After the tears,
Begin the fears…
WHAT WILL I DO?
WHERE WILL I GO?
WHAT WILL HAPPEN TO THE REST OF MY LIFE?
GET UP! STAND UP!
Don’t Give Up the FIGHT!
You gonna win one day, Yes you do, you do….just do it.
Every mistake ought to be a lesson, showing us new and positive times of thought and conduct which we had never appreciated before.
- Accidents are part of the essential experience of life.
- Don’t try to hide or excuse the mistakes done by you.
- Don’t become embittered or frustrated by your mistakes.
- Learn from your mistakes.
Mistakes can either be grindstones wearing away faith and confidence and ability, or they can be stepping stones on which we rise to finer character and richer achievements.
The best thing to do when we have made a mistake is to admit it.
<% This is what I used to smell around my study table during my Engineering. %>
Add comment February 24, 2008
Variable vs Objects
person = “Tim”
p person.object_id
p person.class
p person
#~ 22901710
#~ String
#~ “Tim”
- Ruby creates a new String object with the value “Tim”
- A reference to this object is placed in the local variable person.
- The o/p revels this variable(person) has indeed taken on the personality of a string, with an object id, a type, and a value.
So, is a variable an object?
NO.
- A variable is simply a reference to an object.
- Objects float around in a big pool somewhere (the heap, most of the time) and are pointed to by variables.
person1 = “Tim”
person2 = person1
person2[0] = “J”
p person1.object_id
p person2.object_id
p person1
p person2
#22899620
#22899620
#”Jim”
#”Jim”
variables hold references to objects, not the objects themselves.
- person2 = person1 :: doesn’t create any new objects;
- it simply copies person1’s object reference to person2, so that both
person1 and person2 refer to the same object.
So = symbol here works as an aliasing object >> Gives you multiple variables
And all these variables reference to the same object.
Using dup method:
person1 = “Tim”
person2 = person1.dup
person1[0] = “J”
p person1.object_id
p person2.object_id
p person1
p person2
#~ 22901200
#~ 22901190
#~ “Jim”
#~ “Tim”
But what is your want to prevent from any modifications to the object?
person1 = “Tim”
person2 = person1
person1.freeze # prevent modifications to the object
person2[0] = “J” # can’t modify frozen string (TypeError)
Add comment February 24, 2008

