小编use*_*916的帖子

你怎么称呼这个设计?

在过去的几个小时里,有一种常见的设计模式困在我的脑海中,它一直困扰着我,因为我不记得它的名字.

我不记得这个名字,但至少我可以形容它.

设计是在适当的时间加载库以减轻用户体验,因为他们不需要等待不必要的加载时间.它在启动程序时通常使用.

下面是python中的伪代码

main.py

#main.py    
import platform


if platform.system() == "Darwin":
    from QwertyMac import QwertyMac as Application
elif platform.system() == "Windows":
    from QwertyWindows import QwertyWindows as Application
elif platform.system() == "Linux":
    from QwertyLinux import QwertyLinux as Application
else:
    print "platform is not supported"
    exit()

app = Application()
app.run()
Run Code Online (Sandbox Code Playgroud)

QwertyMac.py

#QwertyMac.py
import sys, thread, time # and other 50++ libs.
Run Code Online (Sandbox Code Playgroud)

QwertyWindows.py

#QwertyWindows.py
import sys, thread, time # and other 50++ libs.
Run Code Online (Sandbox Code Playgroud)

QwertyLinux.py

#QwertyLinux.py
import sys, thread, time # and other …
Run Code Online (Sandbox Code Playgroud)

design-patterns

5
推荐指数
1
解决办法
66
查看次数

Ruby String Match

你怎么做相反的

asd = 'qwe'

asd.match('qwe') do
  p 'it matches'
else
  p 'it doesnt match'
end
Run Code Online (Sandbox Code Playgroud)

反过来,我的意思是

asd.does_not_match('qwe') do
  p 'it doesnt match'
else
 p 'it matches'
end
Run Code Online (Sandbox Code Playgroud)

'不匹配'的语法是什么?

ruby string match

0
推荐指数
1
解决办法
8716
查看次数

strtol有什么问题?

我有这个代码,它应该运行正常,但由于某种原因,循环将循环通过我在循环的条件检查之前释放字符串.从循环中退出的唯一方法是给出超过3位的整数(输入> 99 || input <-99).我正在使用gcc编译此代码,代码:: blocks作为IDE.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char* createString(void);

int main() {

  int temp = 0;
  char* string = 0;
  char* error = 0;

  do {
    printf("\n  Integer: ");
    string = createString();
    temp = strtol(string, &error, 10);
    if (*error != '\n' && *error != '\0') printf("\n  Input is not an integer");
    free(string);
    string = 0;
  } while (*error != '\n' && *error != '\0');
  free(error);
  error = 0;
  return 0;
}

char* createString() {

  char* …
Run Code Online (Sandbox Code Playgroud)

c

-1
推荐指数
2
解决办法
1117
查看次数

标签 统计

c ×1

design-patterns ×1

match ×1

ruby ×1

string ×1