Well if you’re really going for brevity you might as well do this:
break if (str=gets.chomp).empty?
Well if you’re really going for brevity you might as well do this:
break if (str=gets.chomp).empty?
On 31/03/2013, at 1:42 AM, [email protected] wrote:
However, when it comes time to actually maintain code (and all code needs
maintaining), you will probably find simple Ruby to be much easier to read and
understand.
I apologise! You’re absolutely right! This will translate single
characters in place. I didn’t understand what it did. Silly me.
class String
def dna_conv
self.upcase.tr(“ABCDEFGHIJKLMNOPQRSTUVWXYZ”,
“AAAAAABBBBBBCCCCCCDDDDDDDD”)
end
end
puts "DNAS: Sequencing Open… Input? "
while (word=$stdin.gets.chomp).size>1
puts word.dna_conv
puts
puts "DNAS: Additional Input? "
end
Julian
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs