This is what I think is easy way to understand what closure of JavaScript is.
When we use variables in programming, at first we declare it and then use it. So, what happens when I declare the variable which name is already declared?
import sqlite3 | |
import discord | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print('Logged in as') | |
print(client.user.name) |
import discord | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print('Logged in as') | |
print(client.user.name) |
from matplotlib import pyplot as plt | |
import numpy as np | |
import pandas as pd | |
from sympy import sieve | |
def prime_doubles(upper): | |
result = [0] * (2 * upper + 1) | |
sieve.extend(upper) | |
max_prime_index, _ = sieve.search(upper) | |
for i in range(1, max_prime_index+1): |
This is what I think is easy way to understand what closure of JavaScript is.
When we use variables in programming, at first we declare it and then use it. So, what happens when I declare the variable which name is already declared?
let count = 0; | |
const doOnlyOnce = function (){ | |
if(count==0){ | |
console.log("You do this for first time."); | |
}else{ | |
console.log("You already have done this."); | |
} | |
count++; | |
}; |
from functools import wraps | |
from time import time | |
def timing(f): | |
@wraps(f) | |
def wrapper(*args, **kwds): | |
s = time() | |
f(*args, **kwds) | |
return time() - s |
var SLACK_ACCESS_TOKEN = PropertiesService.getScriptProperties().getProperty('SLACK_ACCESS_TOKEN'); | |
var GIPHY_API_KEY = PropertiesService.getScriptProperties().getProperty('GIPHY_API_KEY'); | |
// var SPREAD_SHEET_ID = PropertiesService.getScriptProperties().getProperty('SPREAD_SHEAT_ID'); | |
var POST_MESSAGE_ENDPOINT = 'https://slack.com/api/chat.postMessage'; | |
var TEXTS = [ | |
'Do you like dogs?:dog:', | |
'You said the word!:grinning:', | |
'I hope you like this...:poodle:', | |
'Dogs are cute!:dog2: Dogs are cute!:dog2:', |
class NaturalNumber: | |
def __init__(self, p=None): | |
self.predecessor = p | |
def __eq__(self, x): | |
if self.predecessor is None and x.predecessor is None: | |
return True | |
elif (self.predecessor is None and x.predecessor is not None) \ | |
or (self.predecessor is not None and x.predecessor is None): | |
return False |
var token = 'xoxb-34...みたいなトークン'; | |
var slack = GASlacker.methods(token); | |
function doPost(e){ | |
var event = JSON.parse(e.postData.contents).event; | |
if(event.text.match(/hello/)){ | |
var text = "Hello," + event.message.username; | |
slack.chat.postMessage(event.channel, text); | |
} | |
} |
import sqlite3 | |
import discord | |
client = discord.Client() | |
@client.event | |
async def on_ready(): | |
print('Logged in as') | |
print(client.user.name) |