syntax Questions

7

Solved

I have a couple different virtual environments in a project, e.g. ~/project_dir/sub_dirs/venv/... Adding */venv/* to the .gitignore file does not prevent the virtual environment folders and their...
Mcgrew asked 17/2, 2017 at 20:0

18

Solved

[1, 2, 3, 4].inject(0) { |result, element| result + element } # => 10 I'm looking at this code but my brain is not registering how the number 10 can become the result. Would someone mind expla...
Wattle asked 2/4, 2009 at 16:28

5

Solved

I often see people are using Delimiters. I tried myself to find out what are delimiters and what is their purpose. After 20 minutes of googling, I was not able to find an answer which satisfies me....
Salto asked 21/4, 2012 at 13:51

3

Solved

I do not know much about python so i apologize if my question is a very basic one. Let's say i have a list lst = [1,2,3,4,5,6,7,8,9,10] Now what i want to know is that if there is any way to w...
Houlihan asked 17/11, 2015 at 14:34

13

Solved

Does Haskell have similar syntactic sugar to Python List Slices? For instance in Python: x = ['a','b','c','d'] x[1:3] gives the characters from index 1 to index 2 included (or to index 3 exclu...
Honorary asked 4/1, 2011 at 19:59

7

Solved

I have seen the use of %>% (percent greater than percent) function in some packages like dplyr and rvest. What does it mean? Is it a way to write closure blocks in R?
Pammy asked 25/11, 2014 at 11:37

4

Solved

In C# I can write code to check for null references and in case throw a custom exception, example: var myValue = (someObject?.SomeProperty ?? throw new Exception("...")).SomeProperty; In recent ...
Heavyset asked 27/3, 2020 at 10:44

6

Solved

I have this script called test.sh: #!/bin/bash STR = "Hello World" echo $STR when I run sh test.sh I get this: test.sh: line 2: STR: command not found What am I doing wrong? I look at extreme...
Swamp asked 15/2, 2010 at 18:32

1

title says it all, here's an example. Also, is this preferred in most workflows? I just think it looks pretty. Thanks!
Ornithology asked 13/10, 2020 at 18:15

4

Solved

Is this: if(x != y) { } different from this: if (x is not y) { } Or are there no differences between the two conditions?
Beverage asked 17/11, 2021 at 20:20

21

Solved

I'm writing some code that looks like this: while(true) { switch(msg->state) { case MSGTYPE: // ... break; // ... more stuff ... case DONE: break; // **HERE, I want to break out of the l...
Gayn asked 14/9, 2009 at 6:51

11

Solved

A coworker claimed recently in a code review that the [[ ]] construct is to be preferred over [ ] in constructs like if [ "`id -nu`" = "$someuser" ] ; then echo "I love yo...
Tunstall asked 21/3, 2009 at 15:28

4

Solved

What does the command "-ne" mean in a bash script? For instance, what does the following line from a bash script do? [ $RESULT -ne 0 ]
Villiform asked 17/7, 2013 at 1:14

14

Solved

Is there any difference between: SELECT * FROM users WHERE username="davyjones" and SELECT * FROM users WHERE username LIKE "davyjones"
Bearden asked 1/10, 2009 at 16:25

6

Solved

Say I want to delete the first 100 entries of a Map without recreating the map, and also do this in the most efficient way. Let's say you have a 500 item ES6 Map Object: let map = new Map(... 500...
Poleaxe asked 17/8, 2017 at 8:59

26

Solved

In MySQL you can insert multiple rows like this: INSERT INTO 'tablename' ('column1', 'column2') VALUES ('data1', 'data2'), ('data1', 'data2'), ('data1', 'data2'), ('data1', 'data2'); However...
Lunarian asked 22/10, 2009 at 20:4

4

Solved

As a simple exercise to learn Rust, I've decided to implement a simple binary search: pub fn binary_search(arr: &[i32], key: i32) -> usize { let min: usize = 0; let max: usize = arr.len();...
Shrier asked 29/7, 2016 at 16:18

37

Solved

How do I make Python dictionary members accessible via a dot "."? For example, instead of writing mydict['val'], I'd like to write mydict.val. Also I'd like to access nested dicts this way. For e...
Towrey asked 28/2, 2010 at 18:51

3

Solved

Here's a snippet in which I instantiate a new content object in my service: const newContent = new Content( result.obj.name result.obj.user.firstName, result.obj._id, result.obj.user._id, ); ...
Rock asked 10/4, 2017 at 4:4

11

Solved

In C# what does where T : class mean? Ie. public IList<T> DoThis<T>() where T : class
Methylamine asked 24/9, 2010 at 11:55

3

Solved

I have seen code like this: function($cfg) use ($connections) {} but php.net doesn't seem to mention that function. I'm guessing it's related to scope, but how?
Staves asked 25/10, 2011 at 6:38

5

Solved

Why won't this query work? SELECT 10 AS my_num, my_num*5 AS another_number FROM table In this example, I'm trying to use the my_num alias in other calculations. This results in unknown column "m...
Pyoid asked 16/1, 2010 at 13:38

20

Solved

What are all the array initialization syntaxes that are possible with C#?
Cyclopean asked 15/4, 2011 at 14:27

28

Solved

What do *args and **kwargs mean in these function definitions? def foo(x, y, *args): pass def bar(x, y, **kwargs): pass See What do ** (double star/asterisk) and * (star/asterisk) mean in a fu...

8

Solved

Where in the standard are functions returning functions disallowed? I understand they are conceptually ridiculous, but it seems to me that the grammar would allow them. According to this webpage, a...
Film asked 13/7, 2015 at 15:18

© 2022 - 2024 — McMap. All rights reserved.