06-06-2020, 09:29 PM
(This post was last modified: 06-07-2020, 04:37 AM by kyonides.
Edit Reason: removed an accent on vowel a
)
Something people usually forget is that operators in Ruby are a bit weird.
and follows the logical order, i.e. if check1 and check2
&& does it in the reverse order, e.g. if check2 && check1
There operator precedence DOES matter! && has a higher precedence than and.
So print name and pattern to verify which one isn't a string and when one of them is a regular expression or Regexp instead. Why? That's because the scripter forgot that passing a single string, whether it's the first or second parameter, to a match operator will always throw a TypeError in Ruby. That should NOT happen at all. This happens when you include strings and regular expressions. In my humble opinion he should have picked just one of them to reduce the number of tests needed to run the method.
Solution? I guess it could be something like...
I don't think name should ever be a Regexp. Not even a mad scientist like would ever dare to make it a regular expression.
and follows the logical order, i.e. if check1 and check2
&& does it in the reverse order, e.g. if check2 && check1
There operator precedence DOES matter! && has a higher precedence than and.
So print name and pattern to verify which one isn't a string and when one of them is a regular expression or Regexp instead. Why? That's because the scripter forgot that passing a single string, whether it's the first or second parameter, to a match operator will always throw a TypeError in Ruby. That should NOT happen at all. This happens when you include strings and regular expressions. In my humble opinion he should have picked just one of them to reduce the number of tests needed to run the method.
Solution? I guess it could be something like...
Code:
if (pattern.is_a?(String) and name.include?(pattern)) ||
(pattern.is_a?(Regexp) and !(pattern =~ name).nil?)
I don't think name should ever be a Regexp. Not even a mad scientist like would ever dare to make it a regular expression.
"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