Since certain people took a long time to notice what I was pointing out back then, I'll make it crystal clear now.
You would need to evaluate a string representing a method or an instance variable if there were no other way to access it.
My whole point is that you certainly can retrieve the actual object DIRECTLY by relying on symbols instead.
Here's where the instance_variable_get method comes in handy.
It allows people to skip the evaluation, that is considered to be slow because it first has to parse the string and find out if it's supposed to be just text, a value, a variable holding any value, etc. (Followed very closely by a syntax check.) The method I mentioned here simply looks for the symbol and retrieves its actual variable from a list of instance variables. This means that it knows for sure what kind of object it's expecting to find there from the very beginning, and no longer needs a syntax checker to run at that point.
That reminds me that I hate that cat.
You would need to evaluate a string representing a method or an instance variable if there were no other way to access it.
My whole point is that you certainly can retrieve the actual object DIRECTLY by relying on symbols instead.
Here's where the instance_variable_get method comes in handy.
Code:
instance_variables.each do |sym|
var = instance_variable_get(sym)
puts var.class
end
It allows people to skip the evaluation, that is considered to be slow because it first has to parse the string and find out if it's supposed to be just text, a value, a variable holding any value, etc. (Followed very closely by a syntax check.) The method I mentioned here simply looks for the symbol and retrieves its actual variable from a list of instance variables. This means that it knows for sure what kind of object it's expecting to find there from the very beginning, and no longer needs a syntax checker to run at that point.
That reminds me that I hate that cat.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE