Questions tagged [block]

DO NOT USE This tag is scheduled for removal because it can refer to many different things depending on the use of other tags with it.

This tag has an active burnination. Remove it from questions if a) you can improve the question in other ways at the same time or b) you have 2k+ rep.

Depending on the tags it's used with, it can refer to:

  • Blocking access to certain resources.
  • Blocks specific to the program or language its used within.
  • Blocks in a file system.
3655 questions
26
votes
5 answers

When do you use scope without a statement in C#?

Just recently I found out you can do this in C#: { // google string url = "#"; if ( value > 5 ) url = "http://google.com"; menu.Add( new MenuItem(url) ); } { // cheese string url = "#"; // url has to be redefined…
Dirk Boer
  • 8,522
  • 13
  • 63
  • 111
26
votes
5 answers

jquery validator plugin with display:none form elements

I'm using the validator plugin found here to validate a form. Problem I'm having is if I put the following around a form input element the validation fails:
I need this because I'm…
user1597002
26
votes
3 answers

What is the purpose of using blocks

I want to use blocks in my application, but I don't really know anything about blocks. Can anyone explain how and why I should use blocks in my code?
Ben10
  • 3,221
  • 2
  • 34
  • 61
25
votes
2 answers

File system block size

What is the significance of the file system block size? If my filesystem block size is set at, say 8K, does that mean that all read/write I/O will happen at size 8K? So if my application wants to read say 16 bytes at offset 4097 then a 4K block…
user880946
  • 429
  • 1
  • 5
  • 5
24
votes
3 answers

Ruby do/end vs braces

Why does this map expression produce different results depending on whether I use braces or do/end? a = [1,2,3,4,5] p a.map { |n| n*2 } #=> [2,4,6,8,10] p a.map do |n| n*2 end #=> [1,2,3,4,5]
Grandpa
  • 3,053
  • 1
  • 25
  • 35
24
votes
2 answers

Understanding Scala Blocks

I'm having difficulty finding specific answers to what I know is something trivial. I would like to understand how blocks work in Scala. I come from a java/ruby background and it seems that scala has an entirely different way of using blocks. The…
b1nd
  • 370
  • 6
  • 12
24
votes
1 answer

Difference between blocks and sectors

With reference to this article, there is a line that reads: Because there are limits to the number of blocks, or drive addresses, that an operating system can address. By defining a block as several sectors, an OS can work with bigger hard drives…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
23
votes
2 answers

how to make a weak pointer to self in swift outside of a block

i want to make a weak pointer to self in swift like how we used to in objective-c like __weak Something *weakself = self; I have found people explaining how to use a 'weak self' inside a block, { in [unowned self] ...} but i dont want to…
user1709076
  • 2,538
  • 9
  • 38
  • 59
23
votes
3 answers

Why use a do-end block in Lua?

I keep trying to find answers for this but fail to do so. I wanted to know, what is the do-end block actually used for? It just says values are used when needed in my book so how could I use this? Do I use it to reduce the scope of local variables…
Mayron
  • 2,146
  • 4
  • 25
  • 51
23
votes
1 answer

Objective-C self->_ivar access with explicit vs implicit self->

General Problem Until now, I always thought self->_ivar is equivalent to _ivar. Today I found out that this is not entirely true. See, for example the following code snippet: @interface TestClass : NSObject { NSString…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
22
votes
2 answers

Is there static block in class in python

I am relatively new to python I would like to run a block of code only once for a class. Like the static block in java. for eg: class ABC: execute this once for a class. Is there any such options available in python? In java we write it like…
M S
  • 3,995
  • 3
  • 25
  • 36
22
votes
5 answers

PostgreSQL: invalid page header in block

I'm getting an Error ERROR: invalid page header in block 411 of relation "t_value_time" in my PostgreSQL database. This keeps happening on different machines. Is there a way to prevent it from happening, or at least telling PSQL to ignore the data…
MrBubbles
  • 527
  • 2
  • 5
  • 7
22
votes
3 answers

Change order of blocks via local.xml file

Is it possible to change the order of already existing blocks via the local.xml file? I know you can change the order of a block with the after or before attribute, but how can one change those attributes of existing blocks. For example, if I want…
Pieter Hoste
  • 587
  • 2
  • 8
  • 22
21
votes
1 answer

How does "()" convert statements into expressions in C++?

I have the following code: int main() { int i=0; int j=({int k=3;++i;})+1; // this line return 0; } It compiles and runs. If I remove the () from "this line", then it doesn't compile. I'm just curious what syntax rule is being applied…
Hind Forsum
  • 9,717
  • 13
  • 63
  • 119
21
votes
4 answers

Using context managers without "with" block

Below is an example of my my_create method, and an example of that method in use. @contextmanager def my_create(**attributes): obj = MyObject(**attributes) yield obj obj.save() with my_create(a=10) as new_obj: new_obj.b =…
chmod 777 j
  • 547
  • 1
  • 5
  • 15