Martin Bialasinski
2006-Sep-22 13:22 UTC
Enumerable.inGroupsOf() should fill up with undefined instead of null?
Hi, I cannot add comments to the bugtracker, it seems, so here we go: There is this new method for Enumerables: [1,2,3,4,5].inGroupsOf(3) -> [[1,2,3],[4,5,null]] To me, null is something explicitly set by the user / developer to "no value, not applicable", whereas undefined means "this value was not set explicitly at all". So I wonder, if undefined would be the better default value to indicate "not part of the initial dataset". Bye, Martin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve aka TDD
2006-Sep-22 13:52 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
Martin Bialasinski a écrit :> [1,2,3,4,5].inGroupsOf(3) -> [[1,2,3],[4,5,null]] > > To me, null is something explicitly set by the user / developer to "no > value, not applicable", whereas undefined means "this value was not > set explicitly at all".I do believe the latter values ARE undefined. What you *see* in the text representation is a result of a pending bug in Object.inspect, that displays undefined''s as null''s. See http://dev.rubyonrails.org/ticket/5941 -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-22 14:26 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
On 9/22/06, Christophe Porteneuve aka TDD <tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> I do believe the latter values ARE undefined. What you *see* in the > text representation is a result of a pending bug in Object.inspect, that > displays undefined''s as null''s.They are null alright: inGroupsOf: function(number, fillWith) { fillWith = fillWith || null; --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thomas Fuchs
2006-Sep-22 15:00 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
hmm-- i''ve modelled it after the rails ruby extension[1]. Wikipedia tells us in a somewhat confusing article (no idea if they''re right) [2]. "In Ruby, the designation is called nil." Note that the german version of the article is much clearer and mentions the synonymity of null and nil explicitly. So null in JavaScript should be equal to nil in Ruby. So confused, Thomas [1] http://weblog.rubyonrails.org/2006/3/1/new-in-rails-enumerable- group_by-and-array-in_groups_of [2] http://en.wikipedia.org/wiki/Null_%28computer%29 Am 22.09.2006 um 15:22 schrieb Martin Bialasinski:> > Hi, > > I cannot add comments to the bugtracker, it seems, so here we go: > > There is this new method for Enumerables: > > [1,2,3,4,5].inGroupsOf(3) -> [[1,2,3],[4,5,null]] > > To me, null is something explicitly set by the user / developer to "no > value, not applicable", whereas undefined means "this value was not > set explicitly at all". > > So I wonder, if undefined would be the better default value to > indicate "not part of the initial dataset". > > Bye, > Martin > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thomas Fuchs
2006-Sep-22 15:01 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
Am 22.09.2006 um 15:22 schrieb Martin Bialasinski:> I cannot add comments to the bugtracker, it seems, so here we go:Are you logged in? This is required now (spam-fighting). -- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-22 15:57 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
On 9/22/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote:> > hmm-- i''ve modelled it after the rails ruby extension[1].Which uses nil.> Note that the german version of the article is much clearer and > mentions the synonymity of null and nil explicitly.I believe the english version has some good points, see below.> So null in JavaScript should be equal to nil in Ruby.There are reasons to say nil in Ruby == undefined in Javascript. The Wikipedia article distinguishes between two meanings: Quote: Null is a special value for a pointer (or other kind of object reference) used to signify that the pointer intentionally does not have a target. [...] Some languages use other nomenclature for such a pointer, e.g., nil, undefined, void reference, etc. => undefined in Javascript, nil in Ruby Quote: In many disciplines, the concept of null allows a three-valued logic, with null indicating "unknown value". => null in Javascript. What about Ruby, does it have something similar? Javascript supports both concepts with null and undefined respectively. Using undefined instead of null makes sure, that you can have an array with members using this three-valued logic. Furthermore: "var foo;" depicts a variable that does not have a value. foo is undefined, not null. And I believe this is what the filler elements are. Array members that do not have a value (that are undefined), because they were not part of the original array. Of cause, you can do arr[3] = undefined;, but still: choosing between null and undefined, undefined seems to carry the meaning better than null. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Ryan Gahl
2006-Sep-22 16:52 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
null is a value directly assignable to a variable. "undefined" is a string represntation of a javascript type. var foo; alert(foo == null); // true alert(typeof (foo) == "undefined") // true It makes much more sense, IMHO, for them to be null, since they were unsupplied. Otherwise you are creating new objects in memory (strings of "undefined"), and then the checking comes down to string comparison, when in reality the elements should just be nothing, nil, null. On 9/22/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 9/22/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote: > > > > hmm-- i''ve modelled it after the rails ruby extension[1]. > > Which uses nil. > > > Note that the german version of the article is much clearer and > > mentions the synonymity of null and nil explicitly. > > I believe the english version has some good points, see below. > > > So null in JavaScript should be equal to nil in Ruby. > > There are reasons to say nil in Ruby == undefined in Javascript. > > The Wikipedia article distinguishes between two meanings: > > Quote: Null is a special value for a pointer (or other kind of object > reference) used to signify that the pointer intentionally does not > have a target. [...] Some languages use other nomenclature for such a > pointer, e.g., nil, undefined, void reference, etc. > > => undefined in Javascript, nil in Ruby > > Quote: In many disciplines, the concept of null allows a three-valued > logic, with null indicating "unknown value". > > => null in Javascript. What about Ruby, does it have something similar? > > Javascript supports both concepts with null and undefined > respectively. Using undefined instead of null makes sure, that you can > have an array with members using this three-valued logic. > > Furthermore: "var foo;" depicts a variable that does not have a value. > foo is undefined, not null. And I believe this is what the filler > elements are. Array members that do not have a value (that are > undefined), because they were not part of the original array. > > Of cause, you can do arr[3] = undefined;, but still: choosing between > null and undefined, undefined seems to carry the meaning better than > null. > > > >-- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-954-9798 x2903 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Ryan Gahl
2006-Sep-22 16:55 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
> > Of cause, you can do arr[3] = undefined;, but still: choosing between > null and undefined, undefined seems to carry the meaning better than > null.No, you can''t. You can do arr[3] = "undefined" (string assignment), but not without the quotes as undefined is, well, undefined. On 9/22/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 9/22/06, Thomas Fuchs <t.fuchs-moWQItti3gBl57MIdRCFDg@public.gmane.org> wrote: > > > > hmm-- i''ve modelled it after the rails ruby extension[1]. > > Which uses nil. > > > Note that the german version of the article is much clearer and > > mentions the synonymity of null and nil explicitly. > > I believe the english version has some good points, see below. > > > So null in JavaScript should be equal to nil in Ruby. > > There are reasons to say nil in Ruby == undefined in Javascript. > > The Wikipedia article distinguishes between two meanings: > > Quote: Null is a special value for a pointer (or other kind of object > reference) used to signify that the pointer intentionally does not > have a target. [...] Some languages use other nomenclature for such a > pointer, e.g., nil, undefined, void reference, etc. > > => undefined in Javascript, nil in Ruby > > Quote: In many disciplines, the concept of null allows a three-valued > logic, with null indicating "unknown value". > > => null in Javascript. What about Ruby, does it have something similar? > > Javascript supports both concepts with null and undefined > respectively. Using undefined instead of null makes sure, that you can > have an array with members using this three-valued logic. > > Furthermore: "var foo;" depicts a variable that does not have a value. > foo is undefined, not null. And I believe this is what the filler > elements are. Array members that do not have a value (that are > undefined), because they were not part of the original array. > > Of cause, you can do arr[3] = undefined;, but still: choosing between > null and undefined, undefined seems to carry the meaning better than > null. > > > >-- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-954-9798 x2903 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-22 17:28 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> null is a value directly assignable to a variable. "undefined" is a string > represntation of a javascript type.There is window.undefined which is of the ECMAScript built-in type "Undefined". ECMAScript 4.2> > var foo; > > alert(foo == null); // trueBecause both built-in types, Null and Undefined, evaluate to false in boolean context. ECMAScript 9.2 foo === null // false> Otherwise you are creating new objects in memory (strings of > "undefined"),Not true. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-22 17:31 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Of cause, you can do arr[3] = undefined;,> No, you can''t. You can do arr[3] = "undefined" (string assignment), but not > without the quotes as undefined is, well, undefined.Just try it.>>> var bar = ["a", "b"] >>> bar[0] = undefined >>> bar[undefined,"b"] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Ryan Gahl
2006-Sep-22 17:40 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
Whelp, there I go putting foot in mouth with untested code. Just ran the tests. Yep foo === undefined; yields true Well then. Cheery-o, I''m out of this debate, KOed by Martin. Still, don''t think it much matters in the end. Maybe undefined is more correct, in light of what I just learned, but I''m more used to null for these cases (obviously as I didn''t even know undefined was a real object.). On 9/22/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > null is a value directly assignable to a variable. "undefined" is a > string > > represntation of a javascript type. > > There is window.undefined which is of the ECMAScript built-in type > "Undefined". > ECMAScript 4.2 > > > > > var foo; > > > > alert(foo == null); // true > > Because both built-in types, Null and Undefined, evaluate to false in > boolean context. ECMAScript 9.2 > > foo === null // false > > > Otherwise you are creating new objects in memory (strings of > > "undefined"), > > Not true. > > > >-- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-954-9798 x2903 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-22 18:07 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Still, don''t think it much matters in the end.It matters when you use null to indicated "not specified". Think SQL. I convert NULL values to null in JSON output. In that case, you could not distingish between trailing nulls that were in the original dataset and nulls that were used to fill the group. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Ryan Gahl
2006-Sep-22 18:18 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
In that case why not make your JSON output represent the sql NULLs as an enumeration or other mapping to the corresponding server side null representation. For example, if my server side code were C# I would make the JSON objects equal to something like the following: foo = SqlInt32.Null; On 9/22/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Still, don''t think it much matters in the end. > > It matters when you use null to indicated "not specified". Think SQL. > I convert NULL values to null in JSON output. In that case, you could > not distingish between trailing nulls that were in the original > dataset and nulls that were used to fill the group. > > > >-- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-954-9798 x2903 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-22 19:19 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In that case why not make your JSON output represent the sql NULLs as an > enumeration or other mapping to the corresponding server side null > representation.I am afraid, I do not quite understand you. I use PHP. PHP presents a SQL-NULL as NULL, a PHP data type. And I convert such data to JSON as in [3, 4, 1, null, 2, 4, null]. I believe this to be quite sensible. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Ryan Gahl
2006-Sep-22 19:39 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
NullTypes = { PHP: { NULL: {}}, dotNET: { SqlInt32: { Null: {}}, SqlString: { Null: {}} } }; And then if (foo === NullTypes.PHP.NULL) {..} Using enumerations like this to map JSON objects to the explicit corresponding server types would allow flexibility to map to other variations that might come in and also to adapt this type of mapping to other scenarios, especially if you start wiring up to external web services on various platforms in true mashup fashion (Where the returning JSON could potentially include meta data relating to the underlying platform). But I like to mix in as much structure to this dynamic world as I can. That just comes from my background I guess and discipline. This will probably boil down to a matter of preference, like most things. On 9/22/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > In that case why not make your JSON output represent the sql NULLs as an > > enumeration or other mapping to the corresponding server side null > > representation. > > I am afraid, I do not quite understand you. I use PHP. PHP presents a > SQL-NULL as NULL, a PHP data type. And I convert such data to JSON as > in [3, 4, 1, null, 2, 4, null]. I believe this to be quite sensible. > > > >-- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-954-9798 x2903 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Ryan Gahl
2006-Sep-22 19:57 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
And you can even add helper methods, like so (this could be simplified but for sake of time I''ll just forego a recursive function)... This type of thing would go into a core lib for the project, and maybe admittedly better suited for larger types of applications where structure comes into play more. (NOTE: nullObj would be good to allow a single generic recursive isNull() method on the outer shell object.) NullTypes = { PHP: { NULL: {}, nullObj: this.NULL; isNull: function(obj) { return obj === this.nullObj; } }, dotNET: { SqlInt32: { Null: {}, nullObj: this.Null; isNull: function(obj) { return obj === this.nullObj; } }, SqlString: { Null: {}, nullObj: this.Null; isNull: function(obj) { return obj === this.nullObj; } }, isNull: function(obj) { var isNull = false; for (var p in this) { if (p != "isNull") { isNull = this[p].isNull(obj); if (isNull) break; } } return isNull; } }, isNull: function(obj) { var isNull = false; for (var p in this) { if (p != "isNull") { isNull = this[p].isNull(obj); if (isNull) break; } } return isNull; } }; then... if (NullTypes.IsNull(foo)) {..} On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > NullTypes = { > PHP: { NULL: {}}, > dotNET: { > SqlInt32: { Null: {}}, > SqlString: { Null: {}} > } > }; > > And then > > if (foo === NullTypes.PHP.NULL) {..} > > Using enumerations like this to map JSON objects to the explicit > corresponding server types would allow flexibility to map to other > variations that might come in and also to adapt this type of mapping to > other scenarios, especially if you start wiring up to external web services > on various platforms in true mashup fashion (Where the returning JSON could > potentially include meta data relating to the underlying platform). But I > like to mix in as much structure to this dynamic world as I can. That just > comes from my background I guess and discipline. This will probably boil > down to a matter of preference, like most things. > > On 9/22/06, Martin Bialasinski <klingeling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On 9/22/06, Ryan Gahl <ryan.gahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > In that case why not make your JSON output represent the sql NULLs as > > an > > > enumeration or other mapping to the corresponding server side null > > > representation. > > > > I am afraid, I do not quite understand you. I use PHP. PHP presents a > > SQL-NULL as NULL, a PHP data type. And I convert such data to JSON as > > in [3, 4, 1, null, 2, 4, null]. I believe this to be quite sensible. > > > > > > > > > > > -- > Ryan Gahl > Application Development Consultant > Athena Group, Inc. > Inquire: 1-920-954-9798 x2903 > Blog: http://www.someElement.com >-- Ryan Gahl Application Development Consultant Athena Group, Inc. Inquire: 1-920-954-9798 x2903 Blog: http://www.someElement.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Hi, I just encountered a situation where I want to know the position of the mouse pointer of an element. I consider this a pretty basic functionality, but Prototype gives me only: Event.pointerX(event) Event.pointerY(event) So I thought adding: elementX: function(event) { return this.pointerX(event)-Element.getX(this.element(event)); }, elementY: function(event) { return this.pointerY(event)-Element.getY(this.element(event)); }, But wait there is no Element.getX. I found out that obtaining the X/y of an element is not trivial at all, but even more in this case I expect it to be handled in a library. Do I miss something or has anyone a reliable and fast implementation for Element.getX? Br Fabian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Martin Bialasinski
2006-Sep-25 11:05 UTC
Re: Enumerable.inGroupsOf() should fill up with undefined instead of null?
So, what is the final say on this? If my reasoning was conclusive, the function should be changed soon, before people start depending on the current behaviour. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---