小编Ale*_*lex的帖子

JQuery:对象值

a = {a: 1, b:2},这些在控制台中显示Object {a: 1, b: 2}.

当我这样做时,a.a我得到1.当我这样做时,a[a]我得到了不确定.

这是正常的吗?

我问这个是因为我需要从动态键中获取值. a[product1], a[product2]....

javascript jquery

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

Rails:vs vs map(&:attribute)

假设我们有3个用户 [User name="A"], [User name="B"], [User name="C"]

(检查在线状态)之间是否存在差异:

if User.where(name: "A").first

User.all.map(&:name).include? "A"
Run Code Online (Sandbox Code Playgroud)

谢谢.

sql activerecord ruby-on-rails map

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

Java:为什么从未调用过这个函数?

package main;

class F {
    void f() {
        System.out.print("F.f() ");
        this.g();
    }

    void g() {
        System.out.print("F.g() ");
    }
}

class Fbis extends F {
    void f() {
        System.out.print("Fbis.f() ");
        this.g();
    }

    void g() {
        System.out.print("Fbis.g() ");
        super.f();
    }
}

public class Main {
    public static void main(String[] args) {
        F f = new Fbis();
        ((F) f).f();
    }
}
Run Code Online (Sandbox Code Playgroud)

嗨,我试图理解为什么永远不会调用F类中的g()函数.此代码编译并运行,但会导致无限循环显示:

Fbis.f() Fbis.g() F.f() Fbis.g() F.f() Fbis.g() F.f() Fbis.g() F.f() Fbis.g() F.f() Fbis.g() F.f() Fbis.g() F.f() Fbis.g() F.f() ...
Run Code Online (Sandbox Code Playgroud)

所以会发生什么,是Fbis.f被调用,它调用 …

java inheritance compilation class

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

C:没有这样的文件或目录

当我硬编码cheminopen(chemin, O_RDONLY)一个文件名,程序工作,但是当我离开,如果给open(chemin, O_RDONLY)我弄No such file or directory.

为什么不chemin使用type_fichier?

当我使用printf("%s", chemin)type_fichier我得到'

int type_fichier(char * chemin) {
  int fp;
  if ((fp = open(chemin, O_RDONLY)) == -1) { perror(""); exit(0); }

  struct stat fileStat;
  if(fstat(fp, &fileStat) < 0)
    return 1;

  switch(fileStat.st_mode & S_IFMT) {
    case S_IFBLK:  printf("block device\n");            break;
    case S_IFCHR:  printf("character device\n");        break;
    case S_IFDIR:  printf("directory\n");               break;
    case S_IFIFO:  printf("FIFO/pipe\n");               break;
    case S_IFLNK:  printf("symlink\n");                 break;
    case S_IFREG: …
Run Code Online (Sandbox Code Playgroud)

c file mode file-descriptor

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

Javascript:回合100

我试图围绕一个数字100.

例:

1340 should become 1400
1301 should become 1400
Run Code Online (Sandbox Code Playgroud)

298 should become 300
200 should stay   200
Run Code Online (Sandbox Code Playgroud)

我知道Math.round但它没有圆到100.

我怎样才能做到这一点 ?

javascript math numbers rounding

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