News
you can omit the Q altogether : String Quotation String Ruby     |     you cannot mix double-quoted text inside a double-quoted string, or single-quoted text inside a single-quoted string : String Literal String Ruby     |     you can multiply strings : multiply strings String Ruby     |     you can convert an array on the fly using the collect method : collect Array Ruby     |     yield with proc parameter : yield Method Ruby     |    

dev-code.info

Web Developers

Menu
  • HOME
  • php
  • Perl
  • Ruby
  • JavaScript
  • About Copyright

you can omit the Q altogether : String Quotation String Ruby

January 4, 2020

puts %/No/ 

 

you cannot mix double-quoted text inside a double-quoted string, or single-quoted text inside a single-quoted string : String Literal String Ruby


puts "I said, "Hello.""

 

you can multiply strings : multiply strings String Ruby



puts "abc" * 5

 

you can convert an array on the fly using the collect method : collect Array Ruby


[1, 2, 3, 4].collect { |element| element * 2 }

 

yield with proc parameter : yield Method Ruby


#!/usr/local/bin/ruby

def return_block
  yield
end

def return_proc( &proc )
  yield
end

return_block { puts "Got block!" }
return_proc { puts "Got block, convert to proc!" }

 

Posts navigation

Previous 1 2 3 … 1,572 Next

Recent Posts

  • you open up an I/O stream with dir : IO.popen File Directory Ruby
  • you don't need to use $_ with gets – you can assign the text it reads to any variable: temperature = gets : chomp Development Ruby
  • you don't even have to use single or double quotes to create a string : String Quotation String Ruby
  • you can use the length method on hashes just as you can on arrays. : Hash Length Hash Ruby
  • you can store numbers in hashes : Hash Creation Hash Ruby

Recent Comments

    Categories

    • JavaScript
    • Perl
    • php
    • Ruby
    • ubuntu linux
    dev-code.info | Proudly Powered by WordPress.
    Theme by Grace Themes