Mass-replace tabs with 4-width spacing
This seems to be the predominant choice, and matches the last commit I just made, so I went ahead and converted them all, and changed any, - for example, 2-space indents. Let me know if this is undesired. To understand why I chose to do this, please refer to the previous commit's message.pull/99/head
parent
4df5219c66
commit
ade78aaafb
@ -1,8 +1,15 @@
|
||||
int *int_Ptr; // Declare a pointer variable called iPtr pointing to an int (an int pointer)
|
||||
// It contains an address. That address holds an int value.
|
||||
double *double_Ptr; // Declare a pointer of type double.
|
||||
// Declare a pointer variable called iPtr pointing to an int (an int pointer)
|
||||
// It contains an address. That address holds an int value.
|
||||
int *int_Ptr;
|
||||
|
||||
int a = 5; // Initializes a to the integer value 5
|
||||
int *int_Ptr = &a // Set int_Ptr which is an int pointer to the address of a
|
||||
std::cout << int_Ptr; // Returns the address of a
|
||||
std::cout << *int_Ptr; // Returns 5 because it dereference the pointer to retrieve the value of a.
|
||||
// Declare a pointer of type double.
|
||||
double *double_Ptr;
|
||||
|
||||
// Initializes a to the integer value 5
|
||||
int a = 5;
|
||||
// Set int_Ptr which is an int pointer to the address of `a`.
|
||||
int *int_Ptr = &a
|
||||
// Returns the address of `a`.
|
||||
std::cout << int_Ptr;
|
||||
// Returns 5 because it dereference the pointer to retrieve the value of `a`.
|
||||
std::cout << *int_Ptr;
|
||||
|
@ -1,23 +1,23 @@
|
||||
func main() {
|
||||
// Basic one
|
||||
if x > 0 {
|
||||
return x
|
||||
} else {
|
||||
return -x
|
||||
}
|
||||
|
||||
// You can put one statement before the condition
|
||||
if a := b + c; a < 42 {
|
||||
return a
|
||||
} else {
|
||||
return a - 42
|
||||
}
|
||||
// Basic one
|
||||
if x > 0 {
|
||||
return x
|
||||
} else {
|
||||
return -x
|
||||
}
|
||||
|
||||
// You can put one statement before the condition
|
||||
if a := b + c; a < 42 {
|
||||
return a
|
||||
} else {
|
||||
return a - 42
|
||||
}
|
||||
|
||||
// Type assertion inside if
|
||||
var val interface{}
|
||||
val = "foo"
|
||||
if str, ok := val.(string); ok {
|
||||
fmt.Println(str)
|
||||
}
|
||||
// Type assertion inside if
|
||||
var val interface{}
|
||||
val = "foo"
|
||||
if str, ok := val.(string); ok {
|
||||
fmt.Println(str)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,40 +1,40 @@
|
||||
# Simple function
|
||||
def functionName():
|
||||
return True
|
||||
return True
|
||||
|
||||
# Function with parameters
|
||||
def functionName(a, b):
|
||||
if a < b:
|
||||
return a
|
||||
else:
|
||||
return b
|
||||
def functionName(a, b):
|
||||
if a < b:
|
||||
return a
|
||||
else:
|
||||
return b
|
||||
|
||||
# Return multiple values
|
||||
def functionName(a, b, c):
|
||||
return a, b, c # Returns a tuple
|
||||
return {'return_a':a, 'return_b':b ,'return_c':c } # Returns a dictionary
|
||||
def functionName(a, b, c):
|
||||
return a, b, c # Returns a tuple
|
||||
return {'return_a':a, 'return_b':b ,'return_c':c } # Returns a dictionary
|
||||
|
||||
# Function with default parameters
|
||||
def functionName(a=0, b=1):
|
||||
print(a, b)
|
||||
functionName() # 0 1
|
||||
functionName(3) # 3 1
|
||||
functionName(3, 4) # 3 4
|
||||
def functionName(a=0, b=1):
|
||||
print(a, b)
|
||||
functionName() # 0 1
|
||||
functionName(3) # 3 1
|
||||
functionName(3, 4) # 3 4
|
||||
|
||||
# Calling parameters by name
|
||||
def functionName(a, b, c):
|
||||
print(a, b, c)
|
||||
functionName(0, 1, 2) # 0 1 2
|
||||
functionName(a=2, c=3, b=4) # 2 4 3
|
||||
functionName(2, 3, c=4) # 2 3 4
|
||||
def functionName(a, b, c):
|
||||
print(a, b, c)
|
||||
functionName(0, 1, 2) # 0 1 2
|
||||
functionName(a=2, c=3, b=4) # 2 4 3
|
||||
functionName(2, 3, c=4) # 2 3 4
|
||||
|
||||
# Arbitrary number of parameters
|
||||
def functionName(*args):
|
||||
...
|
||||
functionName(*[1, 2]) # Equivalent of functionName(1, 2)
|
||||
functionName(*[1, 2, 3]) # Equivalent of functionName(1, 2, 3)
|
||||
...
|
||||
functionName(*[1, 2]) # Equivalent of functionName(1, 2)
|
||||
functionName(*[1, 2, 3]) # Equivalent of functionName(1, 2, 3)
|
||||
|
||||
# Arbitrary number of parameters with arbitrary name
|
||||
def functionName(**kwargs):
|
||||
...
|
||||
functionName(**{'a' : 3, 'b' : 4}) # Equivalent of functionName(a=3, b=4)
|
||||
...
|
||||
functionName(**{'a' : 3, 'b' : 4}) # Equivalent of functionName(a=3, b=4)
|
||||
|
Loading…
Reference in New Issue