# Code snippet: can it be done better/shorter?

**URL:** <https://www.ruby-forum.com/t/code-snippet-can-it-be-done-better-shorter/54325>\
**Category:** Ruby\
**Created:** [March 1, 2006, 4:25pm UTC](https://www.ruby-forum.com/t/code-snippet-can-it-be-done-better-shorter/54325 "2006-03-01T16:25:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krekna\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a9adbd/32.png) [@Krekna\_M](https://www.ruby-forum.com/u/Krekna_M)\
**Post date:** [March 1, 2006, 4:25pm UTC](https://www.ruby-forum.com/t/code-snippet-can-it-be-done-better-shorter/54325/1 "2006-03-01T16:25:29Z")

</div>

AFAIC See, this works all right, but my question is, just to learn the  
Ruby style,  
can this be done shorter (better)?

class LineChecker  
def checkline(line)  
if line =~ /Checking:/  
line =~ /\<(._?)\>._\<(.\*)\>/  
from = $1; rcpt = $2  
from = “Unknown” if from == “”  
rcpt = “Unknown” if rcpt == “”  
return ([from,rcpt])  
elsif line =~ /ClamAV-clamd\ result:\ /  
return $’  
else·  
return []·  
end

end  
end

Cheers,  
Krekna
