# Expecting kEND

**URL:** <https://www.ruby-forum.com/t/expecting-kend/96085>\
**Category:** Ruby\
**Created:** [June 25, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/expecting-kend/96085 "2006-06-25T19:54:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [June 25, 2006, 7:54pm UTC](https://www.ruby-forum.com/t/expecting-kend/96085/1 "2006-06-25T19:54:13Z")

</div>

I know this is a literal translation to keyword end, but unsure  
sometimes (right now that is frequent) of where end goes. I know  
there is one to end the method definition.  
However adding one after the if and one after the else , or just one  
for both conditions doesn’t seem to help.

def roman num

if num \<= 4  
i = 1  
rn = (num/i)  
rn.times do  
print “I”

else num \>= 5 && num \<= 9  
v = 5  
rn = (num/v)  
rnm = (num%v)  
rn.times do  
print “V”  
rnm.times do  
print “I”

end

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [June 26, 2006, 5:09pm UTC](https://www.ruby-forum.com/t/expecting-kend/96085/2 "2006-06-26T17:09:16Z")

</div>

Also your else should be elsif, assuming you only want that piece of  
code to execute when num \>= 5 && num \<= 9

---

<div class="post-metadata">

**Author:** ![zanoni](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e99b99/32.png) [@zanoni](https://www.ruby-forum.com/u/zanoni)\
**Post date:** [June 25, 2006, 9:05pm UTC](https://www.ruby-forum.com/t/expecting-kend/96085/3 "2006-06-25T21:05:46Z")

</div>

You need matching ends for def, if and do…

def roman num

if num \<= 4  
i = 1  
rn = (num/i)  
rn.times do  
print “I”  
end

else num \>= 5 && num \<= 9  
v = 5  
rn = (num/v)  
rnm = (num%v)  
rn.times do  
print “V”  
end  
rnm.times do  
print “I”  
end  
end

end
