This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Xcode 4 with opening brace on new line
Is there a way to change the auto adding bracket to start from a new line? So:
if (a != 0) {
}
when { is added, it will be like:
if (a != 0)
{
}
is this possible?
It's kind of tricky after Xcode 4.2. You can check this answer if you want to do it by yourself.
There is also an app called Snippet Edit that can do it for you. But it's not free...
Related
This question already has answers here:
Is there a way to assert if a span element is bold?
(2 answers)
Closed 4 months ago.
This post was edited and submitted for review 4 months ago and failed to reopen the post:
Original close reason(s) were not resolved
I want to test if the text in all selected elements are bold. In a very narrow sense, a text with font-weight 700 is bold. So this seems to work as a test:
cy.get('.foo').should('have.css', 'font-weight', '700');
But IMO very bold is still bold. Thus I would like to test if font-weight is 700 or greater. However, this does not work:
cy.get('.foo').should('have.css', 'font-weight').and('be.gte', 700);
The error says “expected '700' to be a number or a date”.
Any idea how to do it properly?
The font-weight is returned as a string - you can see this in your first code snippet, where you are checking that the font-weight is equal to '700' and not 700.
So, we simply have to parse the string into a number!
cy.get('.foo')
.should('have.css', 'font-weight') // yields the font-weight, as a string
.then(parseInt) // parses the strings
.and('be.gte', 700);
// Alternative if this answer gives you errors in your IDE
cy.get('.foo')
.should('have.css', 'font-weight') // yields the font-weight, as a string
.then((fontWeight) => +fontWeight) // parses the strings
.and('be.gte', 700);
If that seems cumbersome to repeat over and over, you could make a Cypress custom command
Cypress.Commands.add('validateBold', { prevSubject: true }, (subject) => {
return
cy.wrap(subject)
.should('have.css', 'font-weight')
.then((fontWeight) => +fontWeight)
.and('be.gte', 700);
});
This question already has answers here:
PHP If Statement with Multiple Conditions
(11 answers)
Closed 2 years ago.
I had a if statement that return 'active active-c' if the getName is true, but the problem is i wanna put two value on it so I do this:
#if (Route::current()->getName() === 'sonyForm' || 'warnerForm') active active-c #endif
But that ain't work well, how to do that properly?
The other option is to ask the route to check if it matches a set of patterns for the name:
#if (Route::current()->named('sonyForm', 'warnerForm'))
#if (in_array(Route::current()->getName(), ['sonyForm', 'warnerForm']))
active active-c
#endif
This question already has answers here:
how to put a backquote in a backquoted string?
(3 answers)
Closed 2 years ago.
I am trying to initialize a JSON object as a byte in go lang. Here, I am attaching two exmples
var countryRegionData = []byte(`{"name": "srinivas"}`)
var countryRegionData = []byte(`{"name": "srini`vas"}`)
In the first initilization there is no issue, all working as expected.
In the second initialization if you see there is ` between i and v. I have some requirement like this. How to achieve?
A backtick cannot appear in a raw string literal. You can write something like this:
var countryRegionData = []byte("{\"name\": \"srini`vas\"}")
You cannot use escaping in a raw string literal. Either you have to use double-quoted string:
"{\"name\": \"srini'vas\"}"
Or do something like:
`{"name": "srini`+"`"+"vas"}`
This question already has answers here:
Laravel - Pass more than one variable to view
(12 answers)
Closed 2 years ago.
i need to create one variable of text in LARAVEL
if((strlen($tpesquisa ))<4) {
return view('pesquisa');
///////// for example msgm= 'it is necessary to use more than 4 words to start searching';
}
/////////////// for example msgm= 'were found x results';
return view('pesquisa',compact('produtos'));
and in view print the msgm
<p>{{$msgm}}</p>
how create the variable with value text?
and how can I measure the results?
You can just define
$msgm = 'whatever the text'
And then, in the return view you can do:
return view('pesquisa',compact('produtos', 'msgm'));
I decided to learn Swift and I decided to start with Swift 2 right away.
So here is a very basic example that's similar to one of the examples from Apple's own e-book about Swift
let greeting = "Guten Tag"
for index in indices(greeting) {
print(greeting[index])
}
I tried this in the playground of Xcode 7 and I received the following error
Cannot invoke 'indices' with an argument list of type '(String)'
I also tried the same thing with Xcode 6 (which is Swift 1.2 AFAIK) and it worked as expected.
Now, my question is: Is this
An error in Xcode 7, it's still a beta release after all, or
Something that just doesn't work anymore with Swift 2 and the e-book just isn't fully updated yet?
Also: If the answer is "2", how would you replace indices(String) in Swift 2?
In a Playground, if you go to menu View > Debug Area > Show debug area, you can see the full error in the console:
/var/folders/2q/1tmskxd92m94__097w5kgxbr0000gn/T/./lldb/94138/playground29.swift:5:14: error: 'indices' is unavailable: access the 'indices' property on the collection
for index in indices(greeting)
Also, Strings do not conform to SequenceTypes anymore, but you can access their elements by calling characters.
So the solution for Swift 2 is to do it like this:
let greeting = "Guten Tag"
for index in greeting.characters.indices {
print(greeting[index])
}
Result:
G
u
t
e
n
T
a
g
Of course, I assume your example is just to test indices, but otherwise you could just do:
for letter in greeting.characters {
print(letter)
}
Just for completion, I have found a very simple way to get characters and substrings out of strings (this is not my code, but I can't remember where I got it from):
include this String extension in your project:
extension String {
subscript (i: Int) -> Character {
return self[self.startIndex.advancedBy(i)]
}
subscript (i: Int) -> String {
return String(self[i] as Character)
}
subscript (r: Range<Int>) -> String {
return substringWithRange(Range(start: startIndex.advancedBy(r.startIndex), end: startIndex.advancedBy(r.endIndex)))
}
}
this will enable you to do:
print("myTest"[3]) //the result is "e"
print("myTest"[1...3]) //the result is "yTe"
Here is the code that you looking:
var middleName :String? = "some thing"
for index in (middleName?.characters.indices)! {
// do some thing with index
}