dup

practical examples use dup or dup2

Hi, I know what does dup or dup2 do ,but I have no idea when it would be used. Any practical examples? Thanks. ...

String copy using pipes

Hi All, i have written the following code to copy a string "hello world" to another char array using fork and pipes instead of using standard library functions or standard i/o streams. The program is compiling successfully but i am not getting any output. Even, the printf's output are not being shown. # include <string.h> # include <uni...

Duplicating an array of strings.

arr = ["red","green","yellow"] arr2 = arr.clone arr2[0].replace("blue") puts arr.inspect puts arr2.inspect produces: ["blue", "green", "yellow"] ["blue", "green", "yellow"] Is there anyway to do a deep copy of an array of strings, other than using Marshal as i understand that is a hack. I could do: arr2 = [] arr.each do |e| ar...

can't dup NilClass - Error

I am stuck in this error for quite sometime now and have hit a dead end. I get this totally unhelpful error can't dup NilClass This is the situation. I have one class which is in a relationship with another. Say class Parent end class Child < Parent unloadable :has_many :parents, :foreign_key => "child" end The err...

A bug in rails? About model inherited.

My env: ruby-1.9.2-preview3; rails-3.0.0.beta3 class PostFather < ActiveRecord::Base def self.inherited(subclass) end end class Post < PostFather end In the console: > Post.new # => TypeError: can't dup NilClass > Post.all # => TypeError: can't dup NilClass > Post.scoped # => TypeError: can't dup NilClass You can try ...