[#405207] Does `self` and `scope(local)` operate parallels? โ€” "Kumar R." <lists@...>

I am heavily confused with the topic when thinking `self` and `local

21 messages 2013/03/01
[#405211] Re: Does `self` and `scope(local)` operate parallels? โ€” "Kumar R." <lists@...> 2013/03/01

Just to help experts out there I am clearing my statement once again

[#405213] Re: Does `self` and `scope(local)` operate parallels? โ€” "S.D" <s.d@...> 2013/03/01

"Kumar R.": "YAATSGFY"

[#405242] Confusion in instance method calls of super class from subclass โ€” "Kumar R." <lists@...>

I was just playing to see the instance method calls from the subclass

16 messages 2013/03/02
[#405252] Re: Confusion in instance method calls of super class from subclass โ€” Hans Mackowiak <lists@...> 2013/03/03

YOU DID NOT READ WHAT I WAS WRITTEN:

[#405250] Extending Ruby. Little help or guidance if you are willing! โ€” Cliff Rosson <cliff.rosson@...>

Hi Folk,

21 messages 2013/03/03
[#405393] Re: Extending Ruby. Little help or guidance if you are willing! โ€” nannasin smith <lists@...> 2013/03/06

I've tried to do some reading but some of this is a bit over my head.

[#405549] Re: Extending Ruby. Little help or guidance if you are willing! โ€” Cliff Rosson <cliff.rosson@...> 2013/03/10

Haven't been able to touch this in a week but I had a few minutes to look

[#405550] Re: Extending Ruby. Little help or guidance if you are willing! โ€” Bartosz Dziewoล„ski <matma.rex@...> 2013/03/10

On Sun, 10 Mar 2013 04:41:32 +0100, Cliff Rosson <cliff.rosson@gmail.com> wrote:

[#405600] Re: Extending Ruby. Little help or guidance if you are willing! โ€” Cliff Rosson <cliff.rosson@...> 2013/03/11

Got ya. So it doesn't really matter if I convert things to ID and compare

[#405271] Confusion with Ruby's "case/when" block statement โ€” "Kumar R." <lists@...>

Ruby uses `===` operator on the `case/when` type execution style.Now It

13 messages 2013/03/03

[#405310] How `next` works in ruby with `unless` ? โ€” "Kumar R." <lists@...>

The `next` statement is used to skip a part of the loop and continue

25 messages 2013/03/04
[#405311] Re: How `next` works in ruby with `unless` ? โ€” Joel Pearson <lists@...> 2013/03/04

Learn what semicolons do in Ruby.

[#405312] Re: How `next` works in ruby with `unless` ? โ€” Matthew Kerwin <matthew@...> 2013/03/04

What Joel said.

[#405313] Re: How `next` works in ruby with `unless` ? โ€” "Kumar R." <lists@...> 2013/03/04

Matthew Kerwin wrote in post #1100097:

[#405319] Re: How `next` works in ruby with `unless` ? โ€” John W Higgins <wishdev@...> 2013/03/04

What do you think the only possible order of execution would be? It's not

[#405323] YourLanguageSucks โ€” Kiswono Prayogo <kiswono@...>

Hi, i found this link.. https://wiki.theory.org/YourLanguageSucks

10 messages 2013/03/05

[#405376] When can one call themselves a โ€œRubyistโ€? โ€” Rafal Chmiel <lists@...>

I was wondering what that term even meant. Is it something to do with

10 messages 2013/03/05

[#405400] Bignum-Fixnum-Numeric confusion โ€” Pritam Dey <lists@...>

Hi,

13 messages 2013/03/06

[#405444] Question regarding automating some Outlook/IMAP and pdf parsing functions w/ ruby? โ€” Ed Zimmerman <lists@...>

Hello,

20 messages 2013/03/07

[#405477] Compiling Ruby 2.0, problem with OpenSSL โ€” "Piotr P." <lists@...>

Trying to compile Ruby 2.0 from source, having problem with it, getting

10 messages 2013/03/07

[#405495] RubyExcel class. Useful? โ€” Joel Pearson <lists@...>

I've managed to create a (relatively) stable data-processing class which

32 messages 2013/03/08

[#405570] Confusion with block local variable declaration with block variable declaration within the pipe `|` โ€” Love U Ruby <lists@...>

Why are we not allowed to create local variables or new object with

17 messages 2013/03/11

[#405597] Confusion with empty block printing โ€” Love U Ruby <lists@...>

When I typed the below in my IRB:

18 messages 2013/03/11

[#405608] Access values for JSON.parse response โ€” Nicole Villette <lists@...>

Hello, Does anyone know who to get the values from a nested hash in

17 messages 2013/03/11

[#405630] Confusion with some Module methods. โ€” Love U Ruby <lists@...>

Can anyone help me to understand how the below module methods works?

16 messages 2013/03/12

[#405656] Confusion with Strings โ€” Love U Ruby <lists@...>

From the book I read a line about string :

18 messages 2013/03/12

[#405695] ideas on how to determine tag โ€” Wayne Brissette <wbrisett@...>

I'm working on a script that examines a DITA XML file and tries to determine where we put conrefs (where content is being pulled from). I have most of the code working but I'm trying now to determine what type of element something comes from.

9 messages 2013/03/13

[#405762] Understanding Ruby Classes, Objects and Methods. โ€” Kedar Mhaswade <lists@...>

Dear Rubyists,

12 messages 2013/03/13
[#405783] Re: Understanding Ruby Classes, Objects and Methods. โ€” Robert Klemme <shortcutter@...> 2013/03/14

On Wed, Mar 13, 2013 at 11:20 PM, Kedar Mhaswade <lists@ruby-forum.com> wrote:

[#405807] confusion with singleton method call โ€” Love U Ruby <lists@...>

C:\>irb --simple-prompt

11 messages 2013/03/14

[#405931] Finding one's way with 'super' in define_method/alias_emthod โ€” Marcin Rzeลบnicki <marcin.rzeznicki@...>

Hi all!

12 messages 2013/03/18
[#405935] Re: Finding one's way with 'super' in define_method/alias_emthod โ€” Robert Klemme <shortcutter@...> 2013/03/18

On Mon, Mar 18, 2013 at 5:50 PM, Marcin Rzeๆทปnicki

[#405936] Re: Finding one's way with 'super' in define_method/alias_emthod โ€” "Marcin R." <lists@...> 2013/03/18

Robert Klemme wrote in post #1102151:

[#405942] Re: Finding one's way with 'super' in define_method/alias_emthod โ€” Robert Klemme <shortcutter@...> 2013/03/18

On Mon, Mar 18, 2013 at 8:39 PM, Marcin R. <lists@ruby-forum.com> wrote:

[#405986] Ruby tainting on primitives โ€” "Nicolas V." <lists@...>

Hi there,

18 messages 2013/03/20

[#405987] Why was the object_id for true and nil changed in ruby2.0? โ€” Bharadwaj Srigiriraju <lists@...>

irb(main):001:0> true.object_id

11 messages 2013/03/20

[#406015] fixedpnt 0.0.1: Binary Fixed Point Calculations โ€” Axel Friedrich <lists@...>

https://github.com/Axel2/fixedpnt.rb

12 messages 2013/03/20

[#406184] Nokogiri help parsing HTML โ€” Paul Mena <lists@...>

I'm relatively new to Ruby (and therefore Nokogiri) and am trying to

18 messages 2013/03/26

[#406258] Translation Project โ€” Jeremy Henderson <lists@...>

Hello all! This is my first post! I started learning Ruby about 3 weeks

22 messages 2013/03/28

[#406291] Hash with default โ€” Harry Kakueki <list.push@...>

I would like to make a hash like h2 with the default described by h in one

12 messages 2013/03/29

[#406375] Ruby Gotchas presentation slides โ€” Dave Aronson <rubytalk2dave@...>

I recently made available the slides for a presentation I did

13 messages 2013/03/30

[#406387] Private setters can be called by self, why not getters? โ€” Josh Cheek <josh.cheek@...>

class Counter

9 messages 2013/03/31

Re: Hash with default

From: Adam Prescott <adam@...>
Date: 2013-03-29 16:02:40 UTC
List: ruby-talk #406315
On 29 March 2013 15:53, Julian Leviston <julian@coretech.net.au> wrote:
>  h = {"two"=>2,"three"=>3}; def h.[](key); self.has_key?(key) ? super(key) : key; end

Why not use the block to Hash.new instead of overriding #[] ?

>> h = Hash.new { |h,k| k }
=> {}
>> h["one"]
=> "one"
>> h
=> {}

Note this is different than using h[k] = k in the block.

As for the original question, I think you can rely on default_proc and
get around the fact it doesn't return the receiver pretty easily.

>> h = { "two" => 2, "three" => 3 }.tap { |o| o.default_proc = lambda { |h, k| k } }
=> {"two"=>2, "three"=>3}
>> h
=> {"two"=>2, "three"=>3}
>> h["two"]
=> 2
>> h["five"]
=> "five"
>> h
=> {"two"=>2, "three"=>3}

Having said that, I don't see any benefit in trying to get it down to
a single line and sacrificing readability. You can define h to be what
you want, then on a separate line just call #default_proc=.

In This Thread