tracks/groovy/exercises/rna-transcription/Example.groovy in trackler-2.0.1.0 vs tracks/groovy/exercises/rna-transcription/Example.groovy in trackler-2.0.1.1

- old
+ new

@@ -1,20 +1,25 @@ class Complement { - private def dnaMap = ["G":"C","C":"G","T":"A","A":"U"] - private def rnaMap = ["C":"G","G":"C","A":"T","U":"A"] - private def transcribe(seq, seqMap) { - def result = new String() - seq.split('').each() { - result += seqMap[it] + private def dnaMap = ["G":"C","C":"G","T":"A","A":"U"] + private def rnaMap = ["C":"G","G":"C","A":"T","U":"A"] + + private def transcribe(seq, seqMap) { + def result = new String() + seq.split('').each() { + if ( !seqMap[it] ) { + throw new IllegalArgumentException() + } + result += seqMap[it] + } + return result } - return result - } - def ofDNA(strand) { - transcribe(strand, dnaMap) - } + def ofDNA(strand) { + transcribe(strand, dnaMap) + } - def ofRNA(strand) { - transcribe(strand, rnaMap) - } + def ofRNA(strand) { + transcribe(strand, rnaMap) + } + }