conditional

JoptionPane ShowConfirmDialog

妖精的绣舞 提交于 2019-12-22 09:35:57
问题 I have a Java program. When I run the program, it will give me a GUI which as I attached. When I want to close it, it will prompt out a confirm dialog. If I press the Yes button, it will quit the program using System.exit() . public static void main(String args[]) { ButtonTest app = new ButtonTest( ); app.addWindowListener( new WindowAdapter( ) { public void windowClosing (WindowEvent e) { String message = " Really Quit ? "; String title = "Quit"; int reply = JOptionPane.showConfirmDialog

Short Circuiting Operators in an enable_if

雨燕双飞 提交于 2019-12-22 07:59:24
问题 I want to write a templatized function which takes either an array<int, 3> or an int[3] . I'm trying to capture that in an enable_if : template<typename T> enable_if_t<is_array_v<T> && extent_v<T> == 3U || !is_array_v<T> && tuple_size<T>::value == 3U> foo(const T& param) {} Unfortunately for an int[3] , tupple_size is not defined, which causes the template to fail to compile, before short circuiting is evaluated. I have also tried to do this using a conditional but that has the same problem

rails 4 strong params: make them conditional?

馋奶兔 提交于 2019-12-22 07:07:43
问题 Is there a way to make strong_params conditional? Without the need to write 2 separate methods? In case where one would like to add certain attributes to the permit list when a certain condition is true For example: devise_parameter_sanitizer.for(:user) {|u| u.permit(:user, :email, :role, )} I have this :role attribute permitted in above example. I only want this attribute to be permitted when in Rails.env.development is there a way to do this? 回答1: Does this achieve the desired results? user

How to conditionally add attributes to react DOM element

江枫思渺然 提交于 2019-12-22 06:59:07
问题 I have a scenario where I'm using React.js to create a div using the following code : React.createElement('div', {}, "div content") Some additional javascript processing will allow me afterwards to deduce if this div needs to have the className attribute set to" ClassA" or "ClassB" or if it shouldn't have className at all. Is there a way in javascript to access the div that was created from the React DOM and to add to it the className attribute? Note : I couldn't achieve this is JSX so I

Import class conditionally with the keyword 'use'

我的未来我决定 提交于 2019-12-22 05:49:10
问题 I've never seen this structure anywhere, so I wonder if there's something wrong with an expression like this: if (condition) { use Symfony\Component\HttpFoundation\Response; } 回答1: The only thing use does is to alias a class name. That's it. Nothing more. Instead of having to repeatedly write the fully qualified classname in your script: $q = new \Foo\Bar\Baz\Quux; if ($q instanceof \Foo\Bar\Baz\Quux) ... You can shorten that to: use Foo\Bar\Baz\Quux; $q = new Quux; if ($q instanceof Quux) ..

Will a C conditional always return 1 or 0?

佐手、 提交于 2019-12-22 04:04:44
问题 Do C conditional statements always return [1 or 0], or do they return [0 or 'something other than zero']. I ask because: pseudo code - foo(address, shouldSend): register >>= 1 register <<= 1 // to clear bit in first position register |= shouldSend // to signal whether it should send or not the problem occurs if somebody passin IN a shouldSend value of true greater than one (as only 0 is false and all else is true, technically this is valid). since i am directly OR'ing the truth value of

Simple PHP Condition help: if($Var1 = in list($List) and $Cond2) - Is this posslbe?

天大地大妈咪最大 提交于 2019-12-22 03:52:36
问题 Is this a possible function? I need to check if a variable is existent in a list of ones I need to check against and also that cond2 is true eg if($row['name'] == ("1" || "2" || "3") && $Cond2){ doThis(); } It's not working for me and all I changed in the copy paste was my list and the variable names 回答1: if(in_array($row['name'], array('1', '2', '3')) && $Cond2) { doThis(); } PHP's in_array() docs: http://us.php.net/manual/en/function.in-array.php 回答2: You're lookin for the function in_array

Conditional CSS in CSS not working

扶醉桌前 提交于 2019-12-22 01:49:26
问题 so I have this css code: .onetoone{ position: relative; margin: 10px auto 5px; padding: 20px; width: 878px; [if ! IE] height: 1241px; [if IE] height: 241px; border: 1px solid #AAAAAA; behavior: url(PIE.htc); } However I don't see any different height on .onetoone in IE and Firefox, both are still have the same 214px height. It should has a 1232px height in firefox and 241px height in IE 8, right? What did I miss? Thanks for all your answers. 回答1: Have you read the usage file? According the

How would I write an if - elseif - elseif conditional block in an .htaccess file?

≯℡__Kan透↙ 提交于 2019-12-21 20:44:49
问题 This is what I want to accomplish in pseudocode: if server.host equals 'productionsite.com' then RewriteBase / else if server.host equals 'stagingsite.com' then RewriteBase /staging/mysite else if server.host equals 'localhost' or server.host equals '127.0.0.1' then Rewrite /dev/mysite However, this is what I actually have so far which doesn't seem to work as I expect: RewriteCond %{HTTP_HOST} =productionsite.com RewriteBase / RewriteCond %{HTTP_HOST} =stagingsite.com RewriteBase /staging

bash EOF in if statement

这一生的挚爱 提交于 2019-12-21 20:14:21
问题 I am trying to do an action in a IF ELSE statement in Bash, but receive an error like this one: Syntax error: end of file unexpected (expecting "fi") Now I am quite new to this, so probably the solution to my problem should not be that difficult :) if [ "$DAYNAME" = 'Sunday' ]; then echo 'The backup will be uploaded' ftp -n $HOST <<EOF quote USER $USER quote PASS $PASSWD put $filetoday delete ${filethreeweeksago} quit EOF fi Of course the vars are already filled. I think it has to do with the