From ruby-talk-admin@ruby-lang.org Fri Dec 16 02:16:45 2005 Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (8.12.3/8.12.3/Debian-6.6) with ESMTP id jBFHGjZk029218; Fri, 16 Dec 2005 02:16:45 +0900 Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id A99F858BA; Fri, 16 Dec 2005 02:16:49 +0900 (JST) Received: from localhost (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id A78DDF04842; Fri, 16 Dec 2005 02:16:49 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 58DCBF0484A; Fri, 16 Dec 2005 02:16:48 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [210.163.138.100]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 50F04630028; Fri, 16 Dec 2005 02:16:44 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by beryllium.ruby-lang.org (Postfix) with ESMTP id 3AB5233989; Fri, 16 Dec 2005 02:16:44 +0900 (JST) Received: from localhost (beryllium.ruby-lang.org [127.0.0.1]) by beryllium.ruby-lang.org (Postfix) with ESMTP id A6A7933CD8 for ; Fri, 16 Dec 2005 02:16:34 +0900 (JST) Received: from beryllium.ruby-lang.org ([127.0.0.1]) by localhost (beryllium.ruby-lang.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10602-07 for ; Fri, 16 Dec 2005 02:16:34 +0900 (JST) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.205]) by beryllium.ruby-lang.org (Postfix) with ESMTP id 2D9BE33989 for ; Fri, 16 Dec 2005 02:16:33 +0900 (JST) Received: by zproxy.gmail.com with SMTP id 8so408967nzo for ; Thu, 15 Dec 2005 09:16:29 -0800 (PST) Received: by 10.36.222.54 with SMTP id u54mr2048517nzg; Thu, 15 Dec 2005 09:16:28 -0800 (PST) Received: by 10.36.71.19 with HTTP; Thu, 15 Dec 2005 09:16:28 -0800 (PST) Delivered-To: ruby-talk@ruby-lang.org Date: Fri, 16 Dec 2005 02:16:35 +0900 Posted: Thu, 15 Dec 2005 11:16:28 -0600 From: C Erler Reply-To: ruby-talk@ruby-lang.org Subject: Re: Assigning a block to a variable in Ruby To: ruby-talk@ruby-lang.org (ruby-talk ML) Message-Id: <6a9c61b10512150916i10a1a23at@mail.gmail.com> In-Reply-To: <1134665773.927049.245200@z14g2000cwz.googlegroups.com> References: <1134665773.927049.245200@z14g2000cwz.googlegroups.com> X-ML-Name: ruby-talk X-Mail-Count: 72 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-talk-ctl@ruby-lang.org; help= X-Original-To: ruby-talk@ruby-lang.org DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FNw1afISJ/8nvwE9B7qPUU8KmiIAKQ+iRCFxmtMGNwGI08V4JOGbtmhmwevns/0KkvCijjANnfjk0oNoLllig8FAGYsZU4xVpdS/1zIA3NUJFEbsPVGnWRn4Sf+dlfAgdlTs5VKvbN7vfIzltB8iGv7byY2pRAUO62EPDY4wFOQ= Content-Disposition: inline X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ruby-lang.org X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on beryllium.ruby-lang.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=7.0 tests=AWL,BAYES_00,BLARS00, BLARS_SPAM00,CONTENT_TYPE_PRESENT,FAKEDWORD_ATMARK,MIMEQENC,QENCPTR1, QENCPTR2,RCVDFRMLOCALIP,RCVD_BY_IP,RCVD_IN_BLARS,RCVD_IN_BLARS_HOOPS, RCVD_IN_BLARS_SPAM autolearn=ham version=3.0.3 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Precedence: bulk Lines: 36 List-Id: ruby-talk.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: X-Virus-Scanned: by AMaViS snapshot-20020531 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by blade.nagaokaut.ac.jp id jBFHGjZk029218 On 15/12/05, ajmayo@my-deja.com wrote: > Also, I presume Ruby is a forward-referencing language only, unlike > Javascript, where I can declare a function after code which calls it. > Ruby didn't seem to like that much. Ruby will usually wait until code is actually run to check if something is defined. So, if Ruby says that something doesn't exist in your code, the code is being run right then (like when you do stuff inside class x ... end, all of it is run right away). So, you can do things like have two classes that each make an object of the other class, all without needing things like prototypes in C : class A def make_it @b = B.new end end class B def make_it @a = A.new end end This is because those class names are just global variables (technically, constants that can be changed) that have a classes assigned to them. Thus, you can do weird things like assign classes to variables : a = Hash h = a.new This allows you to do things like pass classes into methods so that those methods can do whatever they want with the classes. Hope this helps.