Questions tagged as 'constantes'

1
answer

Constant is it really useful?

Why would I use a constant instead of a variable? Beyond readability, is there another gain in using a constant? I can not tell a difference that makes me use a constant instead of a variable.     
asked by 08.05.2017 / 19:37
1
answer

Why do not the constants in the File class follow the constants convention?

The convention for constants in Java says that a constant must be declared with uppercase letters and the words should be separated by underscore (_). The declaration of a constant is done by the sequence of the keywords static and...
asked by 10.07.2017 / 14:51
1
answer

Should I avoid operations between constants in a loop?

In C ++ is there any sort of optimization or caching that prevents the same mathematical operation between constants from being repeated, especially in loops , thus decreasing application performance? For example: for (int i=0; i<=100;...
asked by 23.04.2018 / 00:56
2
answers

How to make a constant object in JavaScript

How do I declare a constant object in JavaScript? For example: /* meu código */ object_teste = {valor:5} /* console navegador */ object_teste.valor=10; console.log(object_teste.valor) // aqui ele me retorna 10 ao invés de 5 How to leave t...
asked by 12.03.2014 / 20:57
2
answers

Constants of non-primitive types

In Java, constants are declared with the sequences of keywords static and final . When we have public static final int UM = 1; "it makes sense" to call constant, since your value can not be changed. Now, speaking of...
asked by 26.07.2017 / 18:31
3
answers

How to declare a constant in Ruby?

How to declare a constant in Ruby? In other languages I do something like: const CONSTANTE = 1024 And CONSTANTE can not be changed at run time. But I do not think anything like it in Ruby.     
asked by 13.11.2017 / 15:21
2
answers

How to check if a constant exists in the class or in a namespace?

In PHP, to check if a constant exists we use the defined function. As below, for the two cases of constant declaration: const MY_TEST_1 = 'my test 1'; define('MY_TEST_2', 'my test 2'); var_dump(defined('MY_TEST_1'), defined('MY_TEST_2...
asked by 19.06.2015 / 14:06
3
answers

How can I use or name constants for response type fields?

There are situations in which we have fields that represent a type of response, whether they are boolean sim and não , S and N or with multiple answers like the status of something. For example the status of a course c...
asked by 09.07.2018 / 19:38
1
answer

Why, in PHP, are some predefined constants case-insensitive?

Because in PHP , some predefined constants are case-insensitive (they are not case sensitive) and some are not? Example 1: echo __FILE__; // index.php echo __file__; // index.php echo __fiLE__; // index.php Example 2: ec...
asked by 15.07.2015 / 16:29
3
answers

How do I use a constant within a method of a class?

I set a constant in a file and would like to call it inside a method in a class. Example: File: Configuracao.php <?php define('FOO','Hello World'); require_once('Classe.php'); ?> File: Classe.php <?php namespace...
asked by 09.12.2014 / 19:04