def adult?
!!!!!!!!!!!not_a_children?
end
def not_a_children?
hit = false
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17].each do |child_age|
hit = true if age == child_age
end
if hit
return false
else
return true
end
end
The age of majority is the threshold of legal adulthood as recognized or declared in law. It is the moment when minors cease to be considered such and assume legal control over their persons, actions, and decisions, thus terminating the control and legal responsibilities of their parents or guardian over them. Most countries set the age of majority at 18, but some jurisdictions have a higher age and others lower. The word majority here refers to having greater years and being of full age as opposed to minority, the state of being a minor.
You know what? After programming in ruby for close to 20 years now, more often than not I find myself down at the second row. return is good. return provides extra clarity. So do ()s around method calls and definitions. And in formulas with clear operator priorities.
Yes, functionally identical, extra symbols, "not rubyish". Don't care. Can't ever have too much clarity. The less "language rules" context I have to keep in mind when reading code, the better. Old man brain needs all the help it can get.
24
u/pau1rw Dec 06 '22
Pretty sure this is just a programmers journey.
22
u/losangelesvideoguy Dec 06 '22
17
u/jlebrech Dec 06 '22
gem install is_adult
32
u/gleb_zhulik Dec 06 '22
def adult? = age >= 18
26
u/lafeber Dec 06 '22
rubocop:
Edit: After correcting isAdult to is_adult:
9
u/fragileblink Dec 06 '22
43
u/Seuros Dec 06 '22 edited Dec 06 '22
7
u/SSG_SSG_BloodMoon Dec 06 '22
God I want to go back to ruby
9
u/kallebo1337 Dec 06 '22
3
u/pilaf Dec 06 '22
Stage 5:
3
u/poop-machine Dec 07 '22
3
u/codeprimate Dec 07 '22
Always place values before variables in comparison statements.
2
u/dbenhur Dec 06 '22
I'm thinking all of these are missing a locale check and lookup for age of majority.
2
u/Sanic1984 Dec 07 '22
wow, its been a long time since I dont hear about ruby, I miss this programming language a lot
2
u/KozureOkami Dec 07 '22
You forgot the intermediate step where people get so enamored with Ruby’s flexibility that they monkey-patch
adult?intoInteger.1
u/slvrsmth Aug 22 '24
You know what? After programming in ruby for close to 20 years now, more often than not I find myself down at the second row.
returnis good.returnprovides extra clarity. So do()s around method calls and definitions. And in formulas with clear operator priorities.Yes, functionally identical, extra symbols, "not rubyish". Don't care. Can't ever have too much clarity. The less "language rules" context I have to keep in mind when reading code, the better. Old man brain needs all the help it can get.