python-ruby

1.blocks

>> properties = ['object oriented' , 'duck typed' , 'productive' , 'fun' ]

=> ["object oriented" , "duck typed" , "productive" , "fun" ]

>> properties.each {|property| puts "Ruby is #{property}." }

Ruby is object oriented.

Ruby is duck typed.

Ruby is productive.

Ruby is fun.

=> ["object oriented" , "duck typed" , "productive" , "fun" ]

In [9]: map(lambda p:"Python is %s" % p, properties)

Out[9]:

['Python is object oriented',

'Python is duck typed',

'Python is productive',

'Python is fun']

  1. print

irb(main):008:0> x = 1

=> 1

irb(main):009:0> puts 'hello, #{x}'

hello, #{x}

=> nil

irb(main):010:0> puts "hello, #{x}"

hello, 1

=> nil

In [10]: x = 1

In [11]: print 'hello,%d' % x

hello,1