I guess it had to happen sometime... but apparently, I can''t do "return not condition" i have to do "return ! condition" instead... *grumbles* --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, Feb 22, 2007 at 06:37:31PM -0800, Tyler MacDonald wrote:> > I guess it had to happen sometime... > > but apparently, I can''t do > > "return not condition" > > i have to do > > "return ! condition" > > instead... > > *grumbles*return unless condition marcel -- Marcel Molina Jr. <marcel-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marcel Molina Jr. wrote:> On Thu, Feb 22, 2007 at 06:37:31PM -0800, Tyler MacDonald wrote: > >> I guess it had to happen sometime... >> >> but apparently, I can''t do >> >> "return not condition" >> >> i have to do >> >> "return ! condition" >> >> instead... >> >> *grumbles* >> > > return unless condition > > marcel >Ok, Tyler, tell Ruby you''re sorry. ;-) Jamey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marcel Molina Jr. <marcel-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org> wrote:> > but apparently, I can''t do > > "return not condition" > > i have to do > > "return ! condition" > > instead... > return unless conditionUmm... doesnt that just restrict "return"ing to the condition being false? ie; wouldn''t I have to return true unless condition return false if not... well... i''ve learned something new today :-) - Tyler --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamey Cribbs <jcribbs-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote:> > return unless condition > Ok, Tyler, tell Ruby you''re sorry. ;-)I''m afraid I can''t. def invert(huh) return unless huh end if invert false print "it worked!\n" else print "it didn''t work\n" end yields "it didn''t work". :-( it''s a small failing. but it still irks me. it''s okay though ruby, I can forgive you this one time. - Tyler --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It''s all about bind order: return (not false) == return ! false On 2/22/07, Tyler MacDonald <google.com-oTuY4Vk9bUDG8MNy1oJpyw@public.gmane.org> wrote:> > > Jamey Cribbs <jcribbs-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: > > > return unless condition > > Ok, Tyler, tell Ruby you''re sorry. ;-) > > I''m afraid I can''t. > > def invert(huh) > return unless huh > end > > if invert false > print "it worked!\n" > else > print "it didn''t work\n" > end > > yields "it didn''t work". :-( > > it''s a small failing. but it still irks me. it''s okay though ruby, I can > forgive you this one time. > > - Tyler > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Luke Ivers <technodolt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It''s all about bind order: > > return (not false) == return ! falseYes, those two are equivalent, because they both involve extraneous symbols instead of pure expressive english! Like I said, it''s a small thing. And the first thing that''s really irked me, even after I''ve learned it. :-) - Tyler --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, Feb 22, 2007 at 07:01:11PM -0800, Tyler MacDonald wrote:> > Jamey Cribbs <jcribbs-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: > > > return unless condition > > Ok, Tyler, tell Ruby you''re sorry. ;-) > > I''m afraid I can''t. > > def invert(huh) > return unless huh > end > > if invert false > print "it worked!\n" > else > print "it didn''t work\n" > end > > yields "it didn''t work". :-( > > it''s a small failing. but it still irks me. it''s okay though ruby, I can > forgive you this one time.I didn''t get what you wanted to do from your oringal email. return unless condition will indeed return nil if the condition is true and therefore the result of the method invocation will be boolean false, which is not what you had wanted. Like another poster mentioned, not does not bind as tightly as !, so you''d have to use parens if you wanted to use not. I find ''return not condition'' rather unnatural to read though. If this were the last line of a method I''d just get rid of the return entirely and simply do !condition marcel -- Marcel Molina Jr. <marcel-WRrfy3IlpWYdnm+yROfE0A@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tyler MacDonald wrote:> Jamey Cribbs <jcribbs-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: > >>> return unless condition >>> >> Ok, Tyler, tell Ruby you''re sorry. ;-) >> > > I''m afraid I can''t. > > def invert(huh) > return unless huh > end > > if invert false > print "it worked!\n" > else > print "it didn''t work\n" > end > > yields "it didn''t work". :-( >How about this: def invert(huh) return huh ? false : true end Jamey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamey Cribbs <jcribbs-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote:> How about this: > > def invert(huh) > return huh ? false : true > endThat was a unit test... I''m sorry if this is wasting your guys'' time.. I was just venting, *really*. I''m just using "!" instead of "not" now... it just seemed kind of disappointing that "not" didn''t work. - Tyler --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
andy.keep-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-23 12:34 UTC
Re: ruby just pissed me off!
Tyler -- if this is at the end of the function, you don''t need the return! def test_func(foo) not foo end has the same effect you are going for -- (after all ruby has functional language underpinnings) -andy:) On Feb 22, 10:32 pm, Tyler MacDonald <google....-oTuY4Vk9bUDG8MNy1oJpyw@public.gmane.org> wrote:> Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: > > How about this: > > > def invert(huh) > > return huh ? false : true > > end > > That was a unit test... > > I''m sorry if this is wasting your guys'' time.. I was just venting, > *really*. I''m just using "!" instead of "not" now... it just seemed kind of > disappointing that "not" didn''t work. > > - Tyler--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
andy.keep-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Feb-23 12:58 UTC
Re: ruby just pissed me off!
Although, just to add (now that I''ve had a few sips of coffee) I remember being disappointed when I put "return not foo" the first time and it didn''t know what I meant. I mean.. return really should be at the bottom of the barrel as far as order of operations is concerned. Last to be evaluated. -andy:) On Feb 23, 7:34 am, "andy.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andy.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Tyler -- if this is at the end of the function, you don''t need the > return! > > def test_func(foo) > not foo > end > > has the same effect you are going for -- (after all ruby has > functional language underpinnings) > > -andy:) > > On Feb 22, 10:32 pm, Tyler MacDonald <google....-oTuY4Vk9bUDG8MNy1oJpyw@public.gmane.org> > wrote: > > > Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: > > > How about this: > > > > def invert(huh) > > > return huh ? false : true > > > end > > > That was a unit test... > > > I''m sorry if this is wasting your guys'' time.. I was just venting, > > *really*. I''m just using "!" instead of "not" now... it just seemed kind of > > disappointing that "not" didn''t work. > > > - Tyler--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ruby has lots of friends! .... look how quickly everyone came running to defend :) I personally try not to use a "return" unless my method is returning prematurely. and having the last line of a method read not condition seems clearer than return not condition ... I also quite like !condition anyway can this thread win some kind of OpinionBasedThread of the day award :) farms. On Feb 23, 12:58 pm, "andy.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andy.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Although, just to add (now that I''ve had a few sips of coffee) I > remember being disappointed when I put "return not foo" the first time > and it didn''t know what I meant. I mean.. return really should be at > the bottom of the barrel as far as order of operations is concerned. > Last to be evaluated. > > -andy:) > > On Feb 23, 7:34 am, "andy.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andy.k...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Tyler -- if this is at the end of the function, you don''t need the > > return! > > > def test_func(foo) > > not foo > > end > > > has the same effect you are going for -- (after all ruby has > > functional language underpinnings) > > > -andy:) > > > On Feb 22, 10:32 pm, Tyler MacDonald <google....-oTuY4Vk9bUDG8MNy1oJpyw@public.gmane.org> > > wrote: > > > > Jamey Cribbs <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote: > > > > How about this: > > > > > def invert(huh) > > > > return huh ? false : true > > > > end > > > > That was a unit test... > > > > I''m sorry if this is wasting your guys'' time.. I was just venting, > > > *really*. I''m just using "!" instead of "not" now... it just seemed kind of > > > disappointing that "not" didn''t work. > > > > - Tyler--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 22, 2007, at 6:37 PM, Tyler MacDonald wrote:> > I guess it had to happen sometime... > > but apparently, I can''t do > > "return not condition" > > i have to do > > "return ! condition" > > instead... > > *grumbles*What is ''condition''? It could be complicated and I think it''s affecting your outcome. ''not'' is very low in precedence. It will be polite and let everything in ''condition'' evaluate first. ''!'' evaluates before most everything else. Did you try doing... return not (condition) or return (not condition) Jose ....................................................... Jose Hales-Garcia UCLA Department of Statistics jose-oNoWckAxTcaFhjwBz98joA@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
class Object def not(value) !value end end this should help you out! 2007/2/23, Jose Hales-Garcia <jose-oNoWckAxTcaFhjwBz98joA@public.gmane.org>:> > > On Feb 22, 2007, at 6:37 PM, Tyler MacDonald wrote: > > > I guess it had to happen sometime... > > but apparently, I can''t do > > "return not condition" > > i have to do > > "return ! condition" > > instead... > > *grumbles* > > > What is ''condition''? It could be complicated and I think it''s affecting > your outcome. ''not'' is very low in precedence. It will be polite and let > everything in ''condition'' evaluate first. ''!'' evaluates before most > everything else. Did you try doing... > > return not (condition) > > or > > return (not condition) > > Jose > > ....................................................... > Jose Hales-Garcia > UCLA Department of Statistics > jose-oNoWckAxTcaFhjwBz98joA@public.gmane.org > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---