02-18-2010, 06:17 PM
"...methods are lowercase."
Eh... not always, check Math::PI and Math.PI, they're the same thing, possibly it's because they defined a method like this
This is a working scriptlet... It's related with triangle sides.
In this example...
triangle(20,20,35) #=> isosceles
...would belong to the Object class (or BasicObject class if you prefer in Ruby 1.9.1) for those newbies who didn't know about this.
Eh... not always, check Math::PI and Math.PI, they're the same thing, possibly it's because they defined a method like this
Code:
module Anything
def self.Mymethod
puts 'Who cares?'
end
end
This is a working scriptlet... It's related with triangle sides.
Code:
class TriangleError < StandardError
def to_s; 'Wrong lengths for sides' end
end
def triangle(a, b, c)
raise TriangleError unless TriangleSideLengthsValid?(a,b,c)
return puts :equilateral if [a,b,c].uniq.length==1 # all sides are equal
return puts :isosceles if [a,b,c].uniq.length==2 # 2 sides are equal
return puts :scalene if [a,b,c].uniq.length==3 # no sides are equal
end
def TriangleSideLengthsValid?(a,b,c)
ax,bx,cx=[a,b,c].sort
return (ax+bx)>cx
end
In this example...
triangle(20,20,35) #=> isosceles
...would belong to the Object class (or BasicObject class if you prefer in Ruby 1.9.1) for those newbies who didn't know about this.
"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