Questions tagged [andand]
8 questions
6
votes
2 answers
Is there a Python library (or pattern) like Ruby's andand?
For example, I have an object x that might be None or a string representation of a float. I want to do the following:
do_stuff_with(float(x) if x else None)
Except without having to type x twice, as with Ruby's andand library:
require…

Andres Riofrio
- 9,851
- 7
- 40
- 60
5
votes
7 answers
Is there a Javascript equivalent of Ruby's andand?
In trying to make my Javascript unobtrusive, I'm using onLoads to add functionality to s and such. With Dojo, this looks something like:
var coolInput = dojo.byId('cool_input');
if(coolInput) {
dojo.addOnLoad(function() {
…

James A. Rosen
- 64,193
- 61
- 179
- 261
4
votes
4 answers
Is there an andand for Perl?
I'd rather do this:
say $shop->ShopperDueDate->andand->day_name();
vs. this:
say $shop->ShopperDueDate->day_name() if $shop->ShopperDueDate;
Any ideas?
(This idea is inspired by the Ruby andand extension.)
(Actually it is inspired by the Groovy…

Frew Schmidt
- 9,364
- 16
- 64
- 86
4
votes
1 answer
Avoid object_id warning when using andand in Ruby 1.9?
When I load andand in Ruby 1.9 I get the warning
andand.rb:111: warning: undefining 'object_id' may cause serious problem
Does anyone know a way, other than modifying andand to not remove object_id, to avoid this warning?
Thanks!

Alex
- 4,122
- 5
- 34
- 40
3
votes
1 answer
Using ruby's 'case'/'when' method with || or && operators, etc
I just tried to run some code that looked like this
def get_proj4(srid, type=nil)
type.downcase! if type
case type
when nil || "epsg"
open("http://spatialreference.org/ref/epsg/#{srid}/proj4/").read
when "esri"
…

boulder_ruby
- 38,457
- 9
- 79
- 100
0
votes
1 answer
While loop in "Finding Middle of Linked List"
While writing a code for finding the the middle of the linked List. I encounter a problem where I am not able to understand why one one the snipper works while other does not.
Snippet Working
ListNode *slow = head, *fast = head;
…

AxRy
- 13
- 3
0
votes
3 answers
andand chain not working properly
im trying to refactor this code of mine:
test_cases.select{ |x| x.script && x.script.versions && !x.script.versions.empty? }
and use the andand gem. Basic usage just tells us that we substitute andand to the &&(thus the name) so i tried…

corroded
- 21,406
- 19
- 83
- 132
-2
votes
3 answers
Escaping while loop, while conditions are false
I'm seeing this not wait during specified times.
I've been trying to learn c# and don't know exactly what all the syntax is yet. I just want to know if there are better ways of accomplishing this task.
while (DateTime.Now.DayOfWeek ==…

ClaskoTheKnight
- 55
- 7