Sunday, September 18, 2011

More interpretation required for interpreted languages

After I finished ruby koans (and they are absolutely awesome). I started to look at python koans. In the very beginning I realized that there is something extremely silly about programming languages, you still have to write things like below (to avoid introducing not needed empty spaces):
        string = "It was the best of times,\n\
It was the worst of times."

It is not the same as
  
        string = "It was the best of times,\n\
                  It was the worst of times."

Same problem is displayed in ruby koans:
    long_string = %{
It was the best of times,
It was the worst of times.
}

There are times when this is extremely inconvenient, and your style can only be saved by using templates as in:
require "erb"

#test.erb:
# hubba
# hubba <%= oink %>

erb = ERB.new(File.read("test.erb"))
oink = "hubba"

puts erb.result

1 comment:

xanthezaczek said...

Casino & Resort - Jackson City - JTHub
The Casino & Resort 남양주 출장샵 is the perfect destination 여주 출장마사지 to start your day 김제 출장샵 off. 대전광역 출장샵 It's an ideal 나주 출장샵 venue for every enthusiast who loves to explore Mississippi history,