
Chapter 1: Programming Dynamically!In This Chapter✓ Understanding dynamic typing✓ Defining variables✓ Putting dynamic to use✓ Making static operations
778Running with the Dynamic Language Runtime def main Array.new(11) { gets.to_i }.reverse.each do |x| y = f(x) puts “#{x} #{(y>400) ?
Book VIIIChapter 1Programming Dynamically!779Running with the Dynamic Language Runtime dynamic y = f(array[i]); if (y &g
780Running with the Dynamic Language RuntimeAdd to that the reality that C# is making runtime decisions about every single variable throughout the ent
770Shifting C# Toward Dynamic TypingCOM expects that the languages that use it (like VB Classic and C++) will have dynamic types. This made developing
Book VIIIChapter 1Programming Dynamically!771Shifting C# Toward Dynamic Typing ✦ Python ✦ Cobra (my new favorite) ✦ Groovy ✦ Boo ✦ NewspeakProgrammers
772Programming DynamicallyOther benefits to dynamic languages in general show up as you use them more. For instance, macro languages are usually dynam
Book VIIIChapter 1Programming Dynamically!773Programming DynamicallyHowever, we can do this:dynamic newCourse = SomeFunction();newCourse.Schedule();Al
774Putting Dynamic to UseWhat happens if newCourse comes back as something that doesn’t have a Schedule method? You get a runtime error. But there are
Book VIIIChapter 1Programming Dynamically!775Putting Dynamic to Use ✦ int newString = (int) dynamicVariable;: This is an explicit cast to int. The com
776Running with the Dynamic Language RuntimeHere is the compiled C# code: class C { [return: Dynamic] public object MyMethod([Dyna
Book VIIIChapter 1Programming Dynamically!777Running with the Dynamic Language Runtime Figure 1-1: The Dynamic Language Runtime. The runtime helps the
Komentáře k této Příručce