Pass a block

Vidmantas Jan 14, 2013

While this example is not so obvious on first look what the block passed does, here's a small explanation:

when the block is passed to this function, the uniqueness is checked based on a value returned by that block.

For example if it's array of objects with "user_id" method, then this would be:...

Note sure if doco is correct

leriksen Jan 13, 2013

(Note this was an issue in Ruby 1.9.2, 1.9.3 has been corrected, not sure why the generated doc is still incorrect)

Both exist? and exists? use the same underlying C function

==== file.c, line 5444 define_filetest_function("exist?", rb_file_exist_p, 1); define_filetest_function("exists?",...

Example

Manfred Dec 27, 2012

NOTE: you pass all the keys and values in one long list:

fruit = ActiveSupport::OrderedHash[
  'apple',      'Apple',
  'banana',     'Banana',
  'kiwi',       'Kiwi fruit',
]

fruit.keys => ["apple", "banana", "kiwi"]

@drewyoung1

npearson72 Dec 10, 2012 1 thank

Including module in a class does not automatically over-write methods defined with the same name.

Ex:

module Mod def exit(code = 0) puts "Exiting with code #{code}" super end end

class OriginalClass include Mod def exit puts "Original message" end end

OriginalClas...

String to date conversion not necessarily symmetric

MikeBlyth Nov 28, 2012

Note that converting from Date to String and back again is not necessarily symmetric, because the conversion to string may result in a format that is not properly converted by to_date.

For one thing, to_date sets the century argument in _parse to false. Thus if the default date format has a tw...