SóProvas


ID
377602
Banca
FCC
Órgão
TRE-AP
Ano
2011
Provas
Disciplina
Programação
Assuntos

Em relação a blocos e iteradores do Ruby é INCORRETO afirmar:

Alternativas
Comentários
  • Não sou especialista mas o link abaixo explica muito. Imagino que no item D Carlos Chagas quis dizer com "onde" o bloco pai e não ele mesmo.

    http://rubylearning.com/satishtalim/ruby_blocks.html

    A) Ruby Code blocks (called closures in other languages) are definitely one of the coolest features of Ruby and are chunks of code between braces or between do..end that you can associate with method invocations, almost as if they were parameters. 

     

    B) Acredito que seja assim em toda linguagem, porque seria diferente em Ruby? (

    Ps, tecnicamente imagino que TODO iterador (não em muitos casos) possa ser substituído por um laço equivalente, mas melhor não brigar com a banca, até porque em muitos casos é um subconjunto de todos.

     

    C) Acredito que seja igual JS.

     

    D) In the above block, a new feature is being used: block local variable. In short, block local variables shield a block from manipulating variables outside of its scope. This prevents a block from unintentionally clobbering any variables outside its scope. If you don't want to clobber variables, use block local variables for the variables your block creates.

     

    E) You can provide parameters to the call to yield: these will be passed to the block. Within the block, you list the names of the arguments to receive the parameters between vertical bars (|).