Questions tagged [guard-clause]

In function definitions by clauses with pattern matching, guards are Boolean expressions which augment pattern matching with the possibility to skip a pattern even if an argument structure matches the pattern.

In function definitions by clauses with pattern matching, guards are Boolean expressions which augment pattern matching with the possibility to skip a pattern even if an argument structure matches the pattern.

See also:

References

64 questions
0
votes
1 answer

PHPUnit and Guard Clause, not 100% coverage

I have this Guard: protected function validateRemove($key) { if (!isset($this->collection[$key])) { throw new CategoryCollectionBadItemException(); } } And the test: /** * @test * @expectedException…
Torvic
  • 83
  • 1
  • 3
0
votes
1 answer

Is a "guard" method throwing an exception good practice?

Would the following code be considered a "good" practice? It's the controller of an RPC endpoint of a package. The idea is to easily override/extend the validation or authorization for a specific project that includes the package. Could you say that…
shineability
  • 365
  • 1
  • 3
  • 13
0
votes
1 answer

Is it good practice to have angular-templates check scope-variables for "undefined"?

Example: The picture-gallery-directive retrieves pictures and passes them to the scope: var galleryBootstrapData = bootstrapDataService.get('galleryBootstrapData'); $scope.galleryPictures = galleryBootstrapData.pictures; The…
Maral
  • 3
  • 4
-1
votes
1 answer

Haskell gets confused with horizontal lines

I tried to practice haskell a bit but I didn't get the following code to work: rems :: Int -> [Int] -> [Int] rems _ [] = [] rems k (x:xs) | k == x = rems k xs | otherwise [x] ++ rems k xs main = print $ rems 3 [5, 3, 2] This function…
1 2 3 4
5